{"thread":{"id":"23190","subject":"Enumerating all objects in the Git object store","startedAt":"2010-03-26T15:31:28Z","lastAt":"2010-03-27T13:33:57Z","messageCount":8,"participants":["Paul Richards","Johannes Sixt","Jakub Narebski","Nicolas Pitre","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"137868","messageId":"a1138db31003260831q34967f69u9fc8de861f7931b1@mail.gmail.com","threadId":"23190","inReplyTo":null,"subject":"Enumerating all objects in the Git object store","fromName":"Paul Richards","fromEmail":"paul.richards@gmail.com","sentAt":"2010-03-26T15:31:28Z","receivedAt":"2010-03-26T15:31:28Z","isPatch":false,"sender":{"key":"paul.richards@gmail.com","avatar":"https://gravatar.com/avatar/79ad1fd7cbf40f3c342e4f2586a69ecde83b3f05804639cbc709a812d47613d1?d=mp&s=160"},"body":"Hi,\nI'd like to visualize the objects in a Git repository using Graphviz\nand \"dot\".  I'd like to see commits as circles, trees as triangles,\nblobs as rectangles, and have arrows linking these objects showing how\nthey reference each other in the Git DAG.  For small repositories this\nmay be a useful way to visualize how Git objects work.\n\nI could not find a pre-existing script to do this so I am considering\nwriting one.  Is there a way to enumerate all the objects in the Git\nobject store, and for each one figure out its type (commit, tree, or\nblob) and obtain a list of the objects it references?  If not, is\nthere a way to do this for a single object at a time?  (I can then\nsimply recurse through the whole structure.)\n\n\n-- \nPaul Richards\n"},{"id":"137870","messageId":"4BACD86E.4020803@viscovery.net","threadId":"23190","inReplyTo":"a1138db31003260831q34967f69u9fc8de861f7931b1@mail.gmail.com","subject":"Re: Enumerating all objects in the Git object store","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-03-26T15:53:18Z","receivedAt":"2010-03-26T15:53:18Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 3/26/2010 16:31, schrieb Paul Richards:\n> Is there a way to enumerate all the objects in the Git\n> object store, and for each one figure out its type (commit, tree, or\n> blob) and obtain a list of the objects it references?  If not, is\n> there a way to do this for a single object at a time?  (I can then\n> simply recurse through the whole structure.)\n\nUse 'git rev-list --objects --all' to find all objects connected to all\nrefs (use something else than --all if you want to). Do *not* look at the\npath that the tree and blob objects have attached - it is not authorative\ninformation.\n\nUse 'git cat-file -t' to find the type.\n\nUse 'git cat-file -p' to pretty-print the content of an object. Parse it\ndepending on the type that you find.\n\n-- Hannes\n"},{"id":"137871","messageId":"m3zl1vhxjg.fsf@localhost.localdomain","threadId":"23190","inReplyTo":"4BACD86E.4020803@viscovery.net","subject":"Re: Enumerating all objects in the Git object store","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-03-26T16:13:18Z","receivedAt":"2010-03-26T16:13:18Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> Am 3/26/2010 16:31, schrieb Paul Richards:\n> > Is there a way to enumerate all the objects in the Git\n> > object store, and for each one figure out its type (commit, tree, or\n> > blob) and obtain a list of the objects it references?  If not, is\n> > there a way to do this for a single object at a time?  (I can then\n> > simply recurse through the whole structure.)\n> \n> Use 'git rev-list --objects --all' to find all objects connected to all\n> refs (use something else than --all if you want to). Do *not* look at the\n> path that the tree and blob objects have attached - it is not authorative\n> information.\n> \n> Use 'git cat-file -t' to find the type.\n\nFor performance it would be better to feed `git rev-list --objects --all`\noutput to `git cat-file --batch-check` instead.\n \n> Use 'git cat-file -p' to pretty-print the content of an object. Parse it\n> depending on the type that you find.\n\nFor performance it would be better to use `git cat-file --batch`...\nbut on the other hand side you would have to parse \"binary\" tree objects\nrepresentation.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"137878","messageId":"alpine.LFD.2.00.1003261324350.694@xanadu.home","threadId":"23190","inReplyTo":"4BACD86E.4020803@viscovery.net","subject":"Re: Enumerating all objects in the Git object store","fromName":"Nicolas Pitre","fromEmail":"nico@fluxnic.net","sentAt":"2010-03-26T17:25:19Z","receivedAt":"2010-03-26T17:25:19Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Fri, 26 Mar 2010, Johannes Sixt wrote:\n\n> Use 'git rev-list --objects --all' to find all objects connected to all\n> refs (use something else than --all if you want to). Do *not* look at the\n> path that the tree and blob objects have attached - it is not authorative\n> information.\n\nReally??\n\n\nNicolas\n"},{"id":"137894","messageId":"201003262111.48298.j.sixt@viscovery.net","threadId":"23190","inReplyTo":"alpine.LFD.2.00.1003261324350.694@xanadu.home","subject":"Re: Enumerating all objects in the Git object store","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-03-26T20:11:47Z","receivedAt":"2010-03-26T20:11:47Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Freitag, 26. März 2010, Nicolas Pitre wrote:\n> On Fri, 26 Mar 2010, Johannes Sixt wrote:\n> > Use 'git rev-list --objects --all' to find all objects connected to all\n> > refs (use something else than --all if you want to). Do *not* look at the\n> > path that the tree and blob objects have attached - it is not authorative\n> > information.\n>\n> Really??\n\nYes, really. Consider the same content at two differen paths. Now what? \nrev-list will only ever list the object once.\n\n-- Hannes\n"},{"id":"137898","messageId":"alpine.LFD.2.00.1003261621560.694@xanadu.home","threadId":"23190","inReplyTo":"201003262111.48298.j.sixt@viscovery.net","subject":"Re: Enumerating all objects in the Git object store","fromName":"Nicolas Pitre","fromEmail":"nico@fluxnic.net","sentAt":"2010-03-26T20:24:09Z","receivedAt":"2010-03-26T20:24:09Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Fri, 26 Mar 2010, Johannes Sixt wrote:\n\n> On Freitag, 26. März 2010, Nicolas Pitre wrote:\n> > On Fri, 26 Mar 2010, Johannes Sixt wrote:\n> > > Use 'git rev-list --objects --all' to find all objects connected to all\n> > > refs (use something else than --all if you want to). Do *not* look at the\n> > > path that the tree and blob objects have attached - it is not authorative\n> > > information.\n> >\n> > Really??\n> \n> Yes, really. Consider the same content at two differen paths. Now what? \n> rev-list will only ever list the object once.\n\nSure. It is still a valid path though.\n\n\nNicolas\n"},{"id":"137902","messageId":"a1138db31003261411o136145eeu14afe75ee3d170f5@mail.gmail.com","threadId":"23190","inReplyTo":"4BACD86E.4020803@viscovery.net","subject":"Re: Enumerating all objects in the Git object store","fromName":"Paul Richards","fromEmail":"paul.richards@gmail.com","sentAt":"2010-03-26T21:11:07Z","receivedAt":"2010-03-26T21:11:07Z","isPatch":false,"sender":{"key":"paul.richards@gmail.com","avatar":"https://gravatar.com/avatar/79ad1fd7cbf40f3c342e4f2586a69ecde83b3f05804639cbc709a812d47613d1?d=mp&s=160"},"body":"On 26 March 2010 15:53, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Am 3/26/2010 16:31, schrieb Paul Richards:\n>> Is there a way to enumerate all the objects in the Git\n>> object store, and for each one figure out its type (commit, tree, or\n>> blob) and obtain a list of the objects it references?  If not, is\n>> there a way to do this for a single object at a time?  (I can then\n>> simply recurse through the whole structure.)\n>\n> Use 'git rev-list --objects --all' to find all objects connected to all\n> refs (use something else than --all if you want to). Do *not* look at the\n> path that the tree and blob objects have attached - it is not authorative\n> information.\n>\n> Use 'git cat-file -t' to find the type.\n>\n> Use 'git cat-file -p' to pretty-print the content of an object. Parse it\n> depending on the type that you find.\n>\n\nThank you, this looks perfect!\n\nI'll check this out (and perhaps the optimizations suggested by Jakub\nif necessary).\n\n\n-- \nPaul Richards\n"},{"id":"137947","messageId":"4BAE0945.8040406@drmicha.warpmail.net","threadId":"23190","inReplyTo":"a1138db31003260831q34967f69u9fc8de861f7931b1@mail.gmail.com","subject":"Re: Enumerating all objects in the Git object store","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-03-27T13:33:57Z","receivedAt":"2010-03-27T13:33:57Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Paul Richards venit, vidit, dixit 26.03.2010 16:31:\n> Hi,\n> I'd like to visualize the objects in a Git repository using Graphviz\n> and \"dot\".  I'd like to see commits as circles, trees as triangles,\n> blobs as rectangles, and have arrows linking these objects showing how\n> they reference each other in the Git DAG.  For small repositories this\n> may be a useful way to visualize how Git objects work.\n> \n> I could not find a pre-existing script to do this so I am considering\n> writing one.  Is there a way to enumerate all the objects in the Git\n> object store, and for each one figure out its type (commit, tree, or\n> blob) and obtain a list of the objects it references?  If not, is\n> there a way to do this for a single object at a time?  (I can then\n> simply recurse through the whole structure.)\n> \n\nIf you don't care about loose (unreferenced) objects then it's enough to\nwalk through all refs (branches, tags) and, for each ref, look at parent\nand tree references (using git cat-file) and recurse.\n\nIf you don't care about the sha1 of commits you might even want to\n(ab)use git-fast-export for that!\n\nMichael\n"}]}