git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Enumerating all objects in the Git object store

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 26, 2010, 16:13 UTC
Message-ID
<m3zl1vhxjg.fsf@localhost.localdomain>
In-Reply-To
<4BACD86E.4020803@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
Show 13 quoted lines
> Am 3/26/2010 16:31, schrieb Paul Richards:
> > 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.)
> 
> Use 'git rev-list --objects --all' to find all objects connected to all
> refs (use something else than --all if you want to). Do *not* look at the
> path that the tree and blob objects have attached - it is not authorative
> information.
> 
> Use 'git cat-file -t' to find the type.
For performance it would be better to feed `git rev-list --objects --all`
output to `git cat-file --batch-check` instead.
 
> Use 'git cat-file -p' to pretty-print the content of an object. Parse it
> depending on the type that you find.

For performance it would be better to use `git cat-file --batch`... but on the other hand side you would have to parse "binary" tree objects representation.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Johannes SixtNext: Nicolas Pitre
Message 3 of 8 in “Enumerating all objects in the Git object store”
  1. Paul RichardsMar 26, 2010
  2. Johannes SixtMar 26, 2010
  3. Jakub NarebskiMar 26, 2010
  4. Nicolas PitreMar 26, 2010
  5. Johannes SixtMar 26, 2010
  6. Nicolas PitreMar 26, 2010
  7. Paul RichardsMar 26, 2010
  8. Michael J GruberMar 27, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.