Re: identifying blobs (was Re: Memory overrun in http-push.c)
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Mar 2, 2007, 23:10 UTC
- Message-ID
- <Pine.LNX.4.64.0703021505380.3953@woody.linux-foundation.org>
- In-Reply-To
- <7vr6s7dzrh.fsf@assigned-by-dhcp.cox.net>
On Fri, 2 Mar 2007, Junio C Hamano wrote:
Show 9 quoted lines
> > It wasn't that identifying the commit that contained the version > of the file was not needed. It is just there already is a way > to do so, and "to create git command" turns out to be > unnecessary. Something like: > > $ hash=`git hash-object --stdin <$file_in_question` > $ git log -z --raw -r --abbrev=40 | > grep -z '^:[0-7][0-7]* [0-7][0-7]* [0-9a-f][0-9a-f]* '"$hash"'
That's not very nice, because if the blob is already in the *top* commit, and isn't changed in a long long time, you'll not see it until it changes (which is potentially at the root commit when it was introduced).
So it's better to do something like
- get the hash
hash=`git hash-object --stdin <$file_in_question`
- see if it is in the current top of the tree
git ls-tree -r HEAD | cut -d3- | grep ^$hash
- after that, start doing the backwards searching for things where it went away if it was there before (roughly your "git log -z ...")
which should be fairly simple and straightforward.
For extra bonus points, the script could be trivially written so that it allows the user to specify a path limiter, so that you say "can you tell me which version this blob existed in, but I only want to know about drivers/scsi/ and include/scsi/"
Linus