From: Michael Schubert <mschub@elegosoft.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: James Walmsley <james@fullfat-fs.co.uk>,
"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Identify Commit ID from an Extracted Source Snapshot
Date: Fri, 17 Feb 2012 01:14:57 +0100 [thread overview]
Message-ID: <4F3D9C01.5000402@elegosoft.com> (raw)
In-Reply-To: <20120216235240.GA20779@burratino>
On 02/17/2012 12:53 AM, Jonathan Nieder wrote:
> Michael Schubert wrote:
>
>> If your question is more like "how do I tell git to find out where
>> this old code fits in my history and eventually place it there",
>> the answer is: you cannot do it. No VCS will do this and especially
>> not Git.
>
> Wouldn't it be possible to add the tags you want by walking through
> the commit log to find a matching commit for each tarball?
I read the question like "How do I insert / prepend my zipped
*pre-VCS* version (in)to my Git history in an automated fashion".
> For example:
>
> # Usage: "GIT_DIR=<repository> tag-tars <tarballs>"
> # Arguments should be tarballs containing releases in
> # reverse-chronological order.
> # Should be run in an empty directory, which will be
> # used as a workspace.
>
> # save stdin
> exec 3<&0
>
> GIT_DIR=$(git rev-parse --resolve-git-dir "$GIT_DIR") || exit 1
> GIT_INDEX_FILE=$GIT_DIR/index.tag-tars
> export GIT_INDEX_FILE
>
> if test -n "$(git ls-files -c -o | head -1)"
> then
> echo >&2 'fatal: I need an empty directory to work with'
> exit 1
> fi
>
> for tar
> do
> # empty workspace
> git ls-files | xargs rm -f --
> rm -f "$GIT_INDEX_FILE"
>
> # get tree name for tarball
> tar --strip-components=1 -xf "$tar"
> git ls-files -o | git update-index --add --stdin
> tree=$(git write-tree)
>
> # tag the first commit found matching that tree, if any
> git rev-list master |
> while read cmit
> do
> if git diff-tree --quiet $cmit $tree
> then
> git tag -a ${tar%%.*} $cmit <&3
> break
> fi
> done
> done
>
> Variation using --numstat and a path filter to find the closest commit
> ignoring some files instead of an exact match left as an exercise to
> the reader.
Nice, thanks!
prev parent reply other threads:[~2012-02-17 0:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-16 22:06 Identify Commit ID from an Extracted Source Snapshot James Walmsley
2012-02-16 23:00 ` Michael Schubert
2012-02-16 23:19 ` Sam Vilain
2012-02-16 23:43 ` Michael Schubert
2012-02-16 23:53 ` Jonathan Nieder
2012-02-17 0:14 ` Michael Schubert [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=4F3D9C01.5000402@elegosoft.com \
--to=mschub@elegosoft.com \
--cc=git@vger.kernel.org \
--cc=james@fullfat-fs.co.uk \
--cc=jrnieder@gmail.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).