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

Re: [PATCH] Documentation/git-bundle.txt: Dumping contents of any bundle

From
Jeff King <peff@peff.net>
Date
Jan 1, 2009, 19:21 UTC
Message-ID
<20090101192153.GA6536@coredump.intra.peff.net>
In-Reply-To
<87prj7mz50.fsf_-_@jidanni.org>
On Thu, Jan 01, 2009 at 12:24:59PM +0800, jidanni@jidanni.org wrote:
Show 13 quoted lines
> JK> AFAIK, there is no tool to try salvaging strings from an incomplete pack
> JK> (and you can't just run "strings" because the deltas are zlib
> JK> compressed). So if I were in the police forensics department, I think I
> JK> would read Documentation/technical/pack-format.txt and start hacking a
> JK> solution as quickly as possible.
> 
> Hogwash. Patch follows. Maybe even better methods are available.
> [...]
> +$ sed '/^PACK/,$!d' mybundle.bun > mybundle.pack
> +$ git unpack-objects < mybundle.pack
> +$ cd .git/objects
> +$ ls ??/*|tr -d /|git cat-file --batch-check
> +$ ls ??/*|tr -d /|git cat-file --batch

Sorry, no, but your method does not work in the case I described: a thin pack with deltas. In that case, git unpack-objects cannot unpack the object since it lacks the delta, and will skip it. For example:

  # create a bundle with a thin delta blob
  mkdir one && cd one && git init
  cp /usr/share/dict/words . && git add words && git commit -m one
  echo SECRET MESSAGE >>words && git add words && git commit -m two
  git bundle create ../mybundle.bun HEAD^..
  # now try to fetch from it
  mkdir ../two && cd ../two && git init
  git bundle unbundle ../mybundle.bun
  # produces:
  # error: Repository lacks these prerequisite commits:
  # error: b7d1a0ca98ca0e997d4222459d6fc1c9edae6a3f one
  # so try to recover
  sed '/^PACK/,$!d' ../mybundle.bun > mybundle.pack
  git unpack-objects < mybundle.pack
  # Unpacking objects: 100% (3/3), done.
  # fatal: unresolved deltas left after unpacking
  cd .git/objects
  # this will show just two objects: the commit and the tree
  ls ??/* | tr -d /
  # confirm that we don't have the blob or the string of interest
  ls ??/* | tr -d / | git cat-file --batch | grep SECRET

It is nice that unpack-objects continues at all thanks to the recent improvements by Nicolas, so you may be able to get some of the data out. But it just skips over any unresolvable deltas, since we can't make a useful object from them. Maybe it would be worth adding an option to dump the uncompressed deltas to a file or directory so you could run "strings" on them to recover some of the data.

-Peff
Previous: Johannes SchindelinNext: jidanni@jidanni.org
Message 10 of 32 in “How to extract files out of a "git bundle", no matter what?”
  1. jidanni@jidanni.orgDec 19, 2008
  2. Shawn O. PearceDec 19, 2008
  3. Mark LevedahlDec 19, 2008
  4. jidanni@jidanni.orgDec 19, 2008
  5. Jeff KingDec 19, 2008
  6. jidanni@jidanni.orgDec 19, 2008
  7. Jeff KingDec 19, 2008
  8. Documentation/git-bundle.txt: Dumping contents of any bundlejidanni@jidanni.org, Jan 1, 2009
  9. Johannes SchindelinJan 1, 2009
  10. Jeff KingJan 1, 2009
  11. jidanni@jidanni.orgJan 1, 2009
  12. Jeff KingJan 1, 2009
  13. jidanni@jidanni.orgJan 2, 2009
  14. Shawn O. PearceJan 2, 2009
  15. Jeff KingJan 2, 2009
  16. jidanni@jidanni.orgJan 2, 2009
  17. git ls-tree prints wacko file sizes if it can't find the blobjidanni@jidanni.org, Jan 1, 2009
  18. jidanni@jidanni.orgJan 1, 2009
  19. Handle sha1_object_info failures in ls-tree -lAlex Riesen, Jan 1, 2009
  20. git-bundle(1): add no references required simplest casejidanni@jidanni.org, Jan 26, 2009
  21. Junio C HamanoJan 26, 2009
  22. git-bundle(1): add no references required simplest casejidanni@jidanni.org, Jan 29, 2009
  23. jidanni@jidanni.orgFeb 1, 2009
  24. Johannes SchindelinFeb 2, 2009
  25. Junio C HamanoFeb 2, 2009
  26. jidanni@jidanni.orgFeb 4, 2009
  27. Junio C HamanoFeb 4, 2009
  28. jidanni@jidanni.orgFeb 4, 2009
  29. git-bundle doc: update examplesNanako Shiraishi, Feb 4, 2009
  30. Jeff KingFeb 4, 2009
  31. Junio C HamanoFeb 4, 2009
  32. Junio C HamanoDec 19, 2008

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.