From: Jeff King <peff@peff.net>
To: Neal Kreitzinger <nkreitzinger@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: how to determine version of binary
Date: Sun, 6 May 2012 08:43:42 -0400 [thread overview]
Message-ID: <20120506124342.GC26194@sigill.intra.peff.net> (raw)
In-Reply-To: <4FA552C5.7090000@gmail.com>
On Sat, May 05, 2012 at 11:18:13AM -0500, Neal Kreitzinger wrote:
> What about this recipe:
>
> calculate sha1 of dirty deliverable (binary, html, etc)
>
> grep git tree objects for that sha1
>
> somehow determine which of the tree sha1's is newest. Not sure how
> to do that.
>
> grep commit objects for that tree sha1
>
> now you have the last commit containing that file so now you know the
> version of that file.
Your "not sure" step would be to walk the revision graph and look for
the tree in question. So really you would just walk and grep the trees.
If you know the filename (which you do in your instance), then it's not
even that expensive:
git rev-list HEAD |
while read commit; do
if test "`git rev-parse $commit:path/to/file`" = $sha1; then
echo "found it in $commit"
break
fi
done
But note that that does not tell you the revision of the whole project.
It tells you one _possible_ version, because it is one that contains
that file. If you remove the "break" there you can get the full set of
commits. And then you cross-reference that with the set of commits in
another file. And then another, and so on, until you eventually have
narrowed it down to a single commit.
It's kind of slow, mostly because we have to invoke rev-parse over and
over. But I don't think there is a way to print the sha1 of some path
for each revision via the regular revision walker.
You could probably do better by finding trees that contain a particular
sha1, then finding trees that contain that tree, and so forth, until you
have a set of commits that contain those trees. And then you could do
that backwards walk for all of the files in parallel (i.e., only accept
a tree if it matches all of the deliverables you have).
-Peff
next prev parent reply other threads:[~2012-05-06 12:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-05 7:12 how to determine version of binary Neal Kreitzinger
2012-05-05 9:24 ` Jeff King
2012-05-05 16:18 ` Neal Kreitzinger
2012-05-06 12:43 ` Jeff King [this message]
2012-05-05 11:43 ` Sitaram Chamarty
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=20120506124342.GC26194@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=nkreitzinger@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).