I am trying to get a list of all object IDs in a git repository, using libgit2. I can’t seem to find any method for this. Does libgit2 have a method to get all object IDs (or iterate through them), or do I need to read them manually?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What you may be looking for is the
revision walkingAPI.Edit: A thread in the libgit2 mailing list specifically deals with this.
A more precise answer from Vicent Marti (libgit2 maintainer) is
All you have to do is to push every branch and tag oids into the revision walker to recursively walk the commit history. Please note this won’t retrieve dangling commits (commits or chain of commits that are not referenced by a branch nor a tag).
Edit 2: This behavior (similar to
git log --all) has been successfully implemented in libgit2sharp (libgit2 .Net bindings).Edit 3: A new feature has recently been merged which would allow to enumerate all the objects (commits, trees, blobs, …) stored in the object database:
git_odb_foreach().This would be more in line with the
git fsckscenario @MatrixFrog was talking about.git_odb_foreach()documentation