Re: how to determine version of binary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, May 5, 2012 at 12:42 PM, Neal Kreitzinger <nkreitzinger@xxxxxxxxx> wrote:
> Scenario:  I detect a binary file that is 'dirty'.  I don't know how it got
> there.  However, I know it came from a git repo.  So I calculate the sha1 of
> the binary.  What is the git command to determine which commit that binary

make sure you are using 'git hash-object' to compute the sha,
not the system supplied 'sha1sum' or eqvt.

> version first appeared in?  And the last commit that binary appeared in?

Unless it is a frequent need, I would just use git log's --raw
option to search for the first 7 digits of the SHA you found
above.

For example, a very quick one (which does not count odd
situations like the same file appearing multiple times or on
other branches, for instance) is:

    git log --raw | less +/$SHA

You'll want a line where the SHA appears as the second SHA, not
the first one (in case a later commit changed the file it would
also appear as the first sha).  Example, I'm looking for
"14136eb", so I type in

    git log --raw '--format=%n%ncommit: %h subject: %s' | egrep commit\|14136eb | grep -B 1 14136eb

The output I get back is:

    commit: 1cf062f subject: ACCESS_CHECK split into ACCESS_1 and ACCESS_2; docs updated
    :100755 100755 14136eb... 2a57e2d... M	src/gitolite-shell
    --
    commit: b391000 subject: POST_GIT triggers get 4 more arguments
    :100755 100755 20f4e5d... 14136eb... M	src/gitolite-shell

So the commit that introduced this version of this file is
b391000 (1cf062f is a later one where this file got changed to
something else).
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]