* suggested feature: someone mails me a blob, git please tell me what it is
@ 2007-02-16 16:23 Mike Coleman
2007-02-16 16:48 ` Nicolas Pitre
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Mike Coleman @ 2007-02-16 16:23 UTC (permalink / raw)
To: git
Here's a suggestion for a git feature, if git doesn't already have it.
Since git generally doesn't use RCS-style keyword cookies (like
"$Id$"), it'd be nice to have some other way to identify an installed
file. Perhaps you'd want to know exactly what rev a user is running,
for example.
It seems like it should be fairly easy, given a blob (the file), for
git to describe what it knows about it. For example, it could provide
a list of commits that it's a part of, etc. It'd be *really* nice if
only the output of the sha1sum command on the blob were needed. (I
can't recall exactly how git's blob SHA1's are computed--maybe this
isn't feasible.)
Mike
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: suggested feature: someone mails me a blob, git please tell me what it is
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-17 6:10 ` Shawn O. Pearce
2 siblings, 0 replies; 6+ messages in thread
From: Nicolas Pitre @ 2007-02-16 16:48 UTC (permalink / raw)
To: Mike Coleman; +Cc: git
On Fri, 16 Feb 2007, Mike Coleman wrote:
> Here's a suggestion for a git feature, if git doesn't already have it.
> Since git generally doesn't use RCS-style keyword cookies (like
> "$Id$"), it'd be nice to have some other way to identify an installed
> file. Perhaps you'd want to know exactly what rev a user is running,
> for example.
>
> It seems like it should be fairly easy, given a blob (the file), for
> git to describe what it knows about it. For example, it could provide
> a list of commits that it's a part of, etc.
That is possible, but would be expensive similar to git-fsck-objects.
All objects for each commit would need to be searched for the matching
sha1.
> It'd be *really* nice if only the output of the sha1sum command on the
> blob were needed. (I can't recall exactly how git's blob SHA1's are
> computed--maybe this isn't feasible.)
GIT adds a header of its own before object data. You therefore need to
use git-hash-object not sha1sum to get the right sha1 value.
Nicolas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: suggested feature: someone mails me a blob, git please tell me what it is
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
2007-02-17 6:10 ` Shawn O. Pearce
2 siblings, 1 reply; 6+ messages in thread
From: Matthieu Moy @ 2007-02-16 17:14 UTC (permalink / raw)
To: git
"Mike Coleman" <tutufan@gmail.com> writes:
> It seems like it should be fairly easy, given a blob (the file), for
> git to describe what it knows about it. For example, it could provide
> a list of commits that it's a part of, etc. It'd be *really* nice if
> only the output of the sha1sum command on the blob were needed.
"git cat-file -p" does almost this : given the sha1sum for a blob, it
will give the header and the content of the blob ...
> (I can't recall exactly how git's blob SHA1's are computed--maybe
> this isn't feasible.)
... but this is where it doesn't work :
http://www.kernel.org/pub/software/scm/git/docs/v1.5.0/git.html#Discussion
explains that the sha1sum used by git is the one of the blob _plus_
its header, so it's not the one you get with "sha1sum file".
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>).
--
Matthieu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: suggested feature: someone mails me a blob, git please tell me what it is
2007-02-16 17:14 ` Matthieu Moy
@ 2007-02-16 17:37 ` Linus Torvalds
0 siblings, 0 replies; 6+ messages in thread
From: Linus Torvalds @ 2007-02-16 17:37 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: suggested feature: someone mails me a blob, git please tell me what it is
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-17 6:10 ` Shawn O. Pearce
2007-02-17 21:40 ` Andy Parkins
2 siblings, 1 reply; 6+ messages in thread
From: Shawn O. Pearce @ 2007-02-17 6:10 UTC (permalink / raw)
To: Mike Coleman; +Cc: git
Mike Coleman <tutufan@gmail.com> wrote:
> Here's a suggestion for a git feature, if git doesn't already have it.
> Since git generally doesn't use RCS-style keyword cookies (like
> "$Id$"), it'd be nice to have some other way to identify an installed
> file. Perhaps you'd want to know exactly what rev a user is running,
> for example.
>
> It seems like it should be fairly easy, given a blob (the file), for
> git to describe what it knows about it. For example, it could provide
> a list of commits that it's a part of, etc. It'd be *really* nice if
> only the output of the sha1sum command on the blob were needed. (I
> can't recall exactly how git's blob SHA1's are computed--maybe this
> isn't feasible.)
Rather than embedding something like "$Id$" on a per-file basis
use the output of git-describe in your build process to insert the
string into your executable file(s), and then provide a way to let
the user extract it, or insert it with a unique enough pattern that
you can grep for it in the output of `strings`.
This is what git does itself. We replace GIT_VERSION in git.c
with the output of git-describe during compile time (C preprocessor
macro). The value can be printed by the user with `git version`.
We also embed it into some Perl scripts.
git-gui does the same thing, but is a Tcl/Tk script.
--
Shawn.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: suggested feature: someone mails me a blob, git please tell me what it is
2007-02-17 6:10 ` Shawn O. Pearce
@ 2007-02-17 21:40 ` Andy Parkins
0 siblings, 0 replies; 6+ messages in thread
From: Andy Parkins @ 2007-02-17 21:40 UTC (permalink / raw)
To: git; +Cc: Shawn O. Pearce, Mike Coleman
On Saturday 2007, February 17, Shawn O. Pearce wrote:
> Rather than embedding something like "$Id$" on a per-file basis
> use the output of git-describe in your build process to insert the
Actually this isn't entirely enough. The /only/ thing I miss from
subversion is $Id$; but not in source files - that's easily solved with
a bit of git-describe magic in the Makefile - no, I miss embedding it
inkscape generated .svg files, so that my title block on diagrams gets
automatically assigned a version code.
Q: How lazy am I? A: I can't be bothered to say...
Andy
--
Dr Andrew Parkins, M Eng (Hons), AMIEE
andyparkins@gmail.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-02-17 21:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2007-02-17 6:10 ` Shawn O. Pearce
2007-02-17 21:40 ` Andy Parkins
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).