git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "Todd A. Jacobs" <tjacobs@si2services.com>
Cc: git@vger.kernel.org
Subject: Re: Better way to find commit from tarball?
Date: Mon, 6 Sep 2010 15:05:08 -0500	[thread overview]
Message-ID: <20100906200508.GA26371@burratino> (raw)
In-Reply-To: <AANLkTi=ZnZppPu8tT3-sUG6zZM8YnonPwMG_XZhO03up@mail.gmail.com>

Todd A. Jacobs wrote:

>     cd $SOME_WORK_DIR
>     find . -path ./.git -prune -o -print0 | xargs -0 rm
>     tar xvfz $TARBALL
>     for commit in {0..100}; do
>         id="master~${commit}"
>         if git diff --quiet --exit-code "$id"
>         then
>             echo "Matched on commit $id"
>             break
>         fi
>     done
> 
> Someone please tell me there's an easier way to find a matching tree
> when handed a tarball. This works, but seems cumbersome.

If you are lucky and they used "git archive":

	gunzip <$TARBALL | git get-tar-commit-id

Otherwise: maybe something like this[1] will work.

	tar_id=$(
		git init tarball &&
		cd tarball &&
		perl /usr/share/doc/git/contrib/fast-import/import-tars.perl $TARBALL &&
		git rev-parse --verify HEAD:
	) &&
	rm -fr tarball &&
	git rev-list --full-history --format='%h %T' HEAD |
	grep " $tar_id\$"

[1] http://thread.gmane.org/gmane.comp.version-control.git/44750/focus=44849

      reply	other threads:[~2010-09-06 20:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-06 19:55 Better way to find commit from tarball? Todd A. Jacobs
2010-09-06 20:05 ` Jonathan Nieder [this message]

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=20100906200508.GA26371@burratino \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tjacobs@si2services.com \
    /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).