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

Re: Manually decoding a git object

From
Philip Oakley <philipoakley@iee.org>
Date
Feb 20, 2012, 07:58 UTC
Message-ID
<B268B28A80B446BBADED9B3B6BA4B205@PhilipOakley>
In-Reply-To
<CAMocUqRNNXpGOJ2ZG8bWpkieKkVfoo0=Lkevjw+E3Tssw68Hwg@mail.gmail.com>
From: "??" <xudifsd@gmail.com> Sent: Monday, February 20, 2012 4:45 AM
Show 12 quoted lines
> 2012/2/20 Philip Oakley <philipoakley@iee.org>:
>> If I have a renamed file which is a git object, such a "Git_Object", was
>> 8c-something-or-other, what is the easiest way of examining / decoding /
>> recreating the original file (either as its sha1, or a cat-file).
>>
> I don't think I fully understood what you mean, I assume you just move
> an object file from $GIT_DIR/objects/ to somewhere and rename it,
> let's call it "obj", so if you want to exam its content you can just
> simply call "git cat-file -p obj". And you can also use "git cat-file
> -t obj" to exam its object type. If it's a blob you can use "git
> cat-file -p obj > original" to recreate it, else it's meaningless to
> recreate it.

When I tried it from my home directory (not in a git directory): $ git cat-file -p Git-Object fatal: Not a git repository (or any of the parent directories): .git

Because its sha1 isn't yet known I can't put it into the correct .git/objects/xx/ subdirectory of an fresh 'git init', and I have located an unzip programme that will take the plain git object and decode it - they all expect archives.

I've described the background use-case at http://stackoverflow.com/questions/9341278/how-to-track-the-git-directory-in-git-in-its-own-store - the edit links to a typical corporate scenario.

Even just locating a zlib implementation that simply confirms the file stream is compressesd and deflates it would be a start. Philip

Previous: 徐迪Next: Thomas Rast
Message 12 of 17 in “Document format of basic Git objects”
  1. Document format of basic Git objectsNguyễn Thái Ngọc Duy, Feb 15, 2012
  2. Jonathan NiederFeb 15, 2012
  3. Junio C HamanoFeb 15, 2012
  4. Junio C HamanoFeb 16, 2012
  5. Document format of basic Git objectsNguyễn Thái Ngọc Duy, Feb 19, 2012
  6. Junio C HamanoFeb 19, 2012
  7. Junio C HamanoFeb 19, 2012
  8. Nguyen Thai Ngoc DuyFeb 20, 2012
  9. Jeff KingFeb 20, 2012
  10. Manually decoding a git objectPhilip Oakley, Feb 19, 2012
  11. 徐迪Feb 20, 2012
  12. Philip OakleyFeb 20, 2012
  13. Thomas RastFeb 20, 2012
  14. Philip OakleyFeb 20, 2012
  15. Thomas RastFeb 20, 2012
  16. 徐迪Feb 20, 2012
  17. Philip OakleyFeb 20, 2012

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.