Re: Enumerating all objects in the Git object store
- From
Michael J Gruber <git@drmicha.warpmail.net>
- Date
- Mar 27, 2010, 13:33 UTC
- Message-ID
- <4BAE0945.8040406@drmicha.warpmail.net>
- In-Reply-To
- <a1138db31003260831q34967f69u9fc8de861f7931b1@mail.gmail.com>
Paul Richards venit, vidit, dixit 26.03.2010 16:31:
Show 14 quoted lines
> Hi, > I'd like to visualize the objects in a Git repository using Graphviz > and "dot". I'd like to see commits as circles, trees as triangles, > blobs as rectangles, and have arrows linking these objects showing how > they reference each other in the Git DAG. For small repositories this > may be a useful way to visualize how Git objects work. > > I could not find a pre-existing script to do this so I am considering > writing one. Is there a way to enumerate all the objects in the Git > object store, and for each one figure out its type (commit, tree, or > blob) and obtain a list of the objects it references? If not, is > there a way to do this for a single object at a time? (I can then > simply recurse through the whole structure.) >
If you don't care about loose (unreferenced) objects then it's enough to walk through all refs (branches, tags) and, for each ref, look at parent and tree references (using git cat-file) and recurse.
If you don't care about the sha1 of commits you might even want to (ab)use git-fast-export for that!
Michael