libgit2 / pygit2

Python bindings for libgit2

Home Page:https://www.pygit2.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

generator implementation issue with libgit2

cholin opened this issue · comments

commented

As you may have noticed there are some problems to implement a python generator with these *_foreach iterators of libgit2. I've opened an issue libgit2/libgit2#1384 for that. I'll let this issue open to collect some problematic _foreach functions. For the moment there are:

  • git_references_foreach
  • git_note_foreach

Diff seems to support as well some old fashioned way of iterating (not callback based). I'll look into that.

I had a crack at this when I did git_object_foreach.

Currently I'm building a list because I could get it out quickly, and I needed the functionality, but python does support the iter protocol which does what's needed here. The code got pretty hairy reasonably quick but I'm happy to have another stab at it.

commented

git_config_foreach seems problematic as well. Unfortunately it's the only way of iterating config entries and to extending it will be much more work than for notes.

@cholin I peeked at creating a callback-free version of the config API and (as you probably noticed) it will require changes all the way into the config storage backend abstraction, I fear. If you are interested in pursuing it, I'd open an issue on libgit2/libgit2 and specifically cc @ethomson to ask his thoughts on API changes for the config storage backend object. One potential nice thing is that if we replace the existing foreach() callback with a simpler enumeration API, things like the pattern matching behavior could possibly be moved into common code instead of having to be supported by each backend implementation.

commented

I wanted to get a closer look at this in the next days. I already talked to @carlosmn about git_config (and the default backend). Would be great if you can open an issue for that!