How to get all object identifiers?

I am trying to get a list of all object identifiers in a git repository using libgit2. It seems I can not find any method for this. Does libgit2 have a method for getting all the identifiers of objects (or repeating them through them), or do I need to manually read them?

+7
source share
1 answer

What you might be looking for is the revision walking API.

  • Description of the function can be found here .
  • A test showing different walking strategies can also help you with your help.

Edit: thread in libgit2 mailing list .

More accurate answer from Vicent Marti (proponent of libgit2)

... just push all the HEAD into the walker. You will not receive any duplicates.

All you have to do is click on each branch and tags during the revision to recursively go through the commit history. Please note that this will not lead to cheated commits (commits or chaining commits that are not referenced by any thread or tag).

Edit 2: This behavior (similar to git log --all ) was successfully implemented in libgit2sharp (libgit2. Network bindings).

Edit 3: Recently, a new function has been merged that would allow listing all objects (commits, trees, drops, ...) stored in the object database: git_odb_foreach() .

This will be more consistent with the git fsck script @MatrixFrog talked about.

+7
source

All Articles