From: Linus Torvalds <torvalds@linux-foundation.org>
To: Matthieu Moy <Matthieu.Moy@imag.fr>
Cc: git@vger.kernel.org
Subject: Re: suggested feature: someone mails me a blob, git please tell me what it is
Date: Fri, 16 Feb 2007 09:37:55 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.64.0702160930130.20368@woody.linux-foundation.org> (raw)
In-Reply-To: <vpqr6sq58j8.fsf@olympe.imag.fr>
On Fri, 16 Feb 2007, Matthieu Moy wrote:
>
> But it should be possible to recompute the git sha1sum by recomputing
> the magic formula sha1sum(<ascii type without space> + <space> +
> <ascii decimal size> + <byte\0> + <binary object data>).
Yes. Try this:
[torvalds@woody git]$ ls -l Makefile
-rw-rw-rw- 1 torvalds torvalds 27586 Feb 14 13:35 Makefile
[torvalds@woody git]$ ( echo -en "blob 27586\0" ; cat Makefile ) | sha1sum
ebecbbd9c28390654ed9fea2ff4ebf6a5a317c70 -
[torvalds@woody git]$ git ls-tree HEAD Makefile
100644 blob ebecbbd9c28390654ed9fea2ff4ebf6a5a317c70 Makefile
and notice how the SHA1's match (ebecbb..).
Now, finding all of the copies of that particular object in history is
pretty expensive. You'll basically have to do something like
git rev-list --all |
while read i
do
files=$(git ls-tree -r $i | grep $SHA1)
if [ -n "$files" ]
then
git cat-file -p $i
echo $files
echo
fi
done
which is quite expensive. You can probably start from "git fsck" and ask
it to print out where it found something (but then it will print out only
the first time it found it - because it avoids walking trees more than
once it won't report on it unless if finds it in two trees that are
different).
Linus
next prev parent reply other threads:[~2007-02-16 17:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-16 16:23 suggested feature: someone mails me a blob, git please tell me what it is Mike Coleman
2007-02-16 16:48 ` Nicolas Pitre
2007-02-16 17:14 ` Matthieu Moy
2007-02-16 17:37 ` Linus Torvalds [this message]
2007-02-17 6:10 ` Shawn O. Pearce
2007-02-17 21:40 ` Andy Parkins
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=Pine.LNX.4.64.0702160930130.20368@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=Matthieu.Moy@imag.fr \
--cc=git@vger.kernel.org \
/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).