4

How can I retrieve the total number of git objects in a repository? (I search something like the git count-objects in JGit.)

I made a Java program that calculates statistic values and has to read every object (blob, tree, commit, tag) of a git repository. Something like a progress bar should show the user how many objects already have been processed. So I need the total number of git objects.

Sonson
  • 1,129
  • 1
  • 11
  • 14

1 Answers1

2

I did not manipulate the Git objects at all, but I suppose you should explore the Repository object, which has methods like getAllRefs() or getObjectDatabase().

From the results, I imagine you could find what you want.

Martin Buberl
  • 45,844
  • 25
  • 100
  • 144
Vince
  • 164
  • 2
  • I didn't found out how to get the number of `git count-objects` until now, but this answer was nevertheless very helpful for me. – Sonson Nov 23 '11 at 10:03