git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: jidanni@jidanni.org
Cc: Nicolas Pitre <nico@cam.org>,
	gitster@pobox.com, mdl123@verizon.net, spearce@spearce.org,
	git@vger.kernel.org
Subject: Re: [PATCH] Documentation/git-bundle.txt: Dumping contents of any bundle
Date: Thu, 1 Jan 2009 14:21:54 -0500	[thread overview]
Message-ID: <20090101192153.GA6536@coredump.intra.peff.net> (raw)
In-Reply-To: <87prj7mz50.fsf_-_@jidanni.org>

On Thu, Jan 01, 2009 at 12:24:59PM +0800, jidanni@jidanni.org wrote:

> 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

  parent reply	other threads:[~2009-01-01 19:23 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-19 19:29 How to extract files out of a "git bundle", no matter what? jidanni
2008-12-19 19:32 ` Shawn O. Pearce
2008-12-19 19:57   ` Mark Levedahl
2008-12-19 20:13     ` jidanni
2008-12-19 20:21       ` Jeff King
2008-12-19 20:35         ` jidanni
2008-12-19 20:51           ` Jeff King
2009-01-01  4:24             ` [PATCH] Documentation/git-bundle.txt: Dumping contents of any bundle jidanni
2009-01-01 17:03               ` Johannes Schindelin
2009-01-01 19:21               ` Jeff King [this message]
2009-01-01 22:12                 ` jidanni
2009-01-01 23:48                   ` Jeff King
2009-01-02  0:10                     ` jidanni
2009-01-02  7:15                       ` Shawn O. Pearce
2009-01-02  8:27                         ` Jeff King
2009-01-02 22:03                           ` jidanni
2009-01-01 23:18                 ` git ls-tree prints wacko file sizes if it can't find the blob jidanni
2009-01-01 23:47                   ` jidanni
2009-01-01 23:52                   ` [PATCH] Handle sha1_object_info failures in ls-tree -l Alex Riesen
2009-01-26 19:02       ` [PATCH] git-bundle(1): add no references required simplest case jidanni
2009-01-26 19:53         ` Junio C Hamano
2009-01-29 15:32           ` [PATCH,v2] " jidanni
2009-02-01 23:42             ` jidanni
2009-02-02  0:04               ` Johannes Schindelin
2009-02-02  0:45                 ` Junio C Hamano
2009-02-04  0:09                   ` jidanni
2009-02-04  2:07                     ` Junio C Hamano
2009-02-04  2:18                       ` jidanni
2009-02-04  9:15                       ` [PATCH] git-bundle doc: update examples Nanako Shiraishi
2009-02-04 15:26                         ` Jeff King
2009-02-04 22:44                         ` Junio C Hamano
2008-12-19 20:07 ` How to extract files out of a "git bundle", no matter what? Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090101192153.GA6536@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jidanni@jidanni.org \
    --cc=mdl123@verizon.net \
    --cc=nico@cam.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).