{"thread":{"id":"6847","subject":"suggested feature: someone mails me a blob, git please tell me what it is","startedAt":"2007-02-16T16:23:40Z","lastAt":"2007-02-17T21:40:51Z","messageCount":6,"participants":["Mike Coleman","Nicolas Pitre","Matthieu Moy","Linus Torvalds","Shawn O. Pearce","Andy Parkins"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"34806","messageId":"3c6c07c20702160823j316c52f4pe4cf5ca8a882e194@mail.gmail.com","threadId":"6847","inReplyTo":null,"subject":"suggested feature: someone mails me a blob, git please tell me what it is","fromName":"Mike Coleman","fromEmail":"tutufan@gmail.com","sentAt":"2007-02-16T16:23:40Z","receivedAt":"2007-02-16T16:23:40Z","isPatch":false,"sender":{"key":"tutufan@gmail.com","avatar":null},"body":"Here's a suggestion for a git feature, if git doesn't already have it.\n Since git generally doesn't use RCS-style keyword cookies (like\n\"$Id$\"), it'd be nice to have some other way to identify an installed\nfile.  Perhaps you'd want to know exactly what rev a user is running,\nfor example.\n\nIt seems like it should be fairly easy, given a blob (the file), for\ngit to describe what it knows about it.  For example, it could provide\na list of commits that it's a part of, etc.  It'd be *really* nice if\nonly the output of the sha1sum command on the blob were needed.  (I\ncan't recall exactly how git's blob SHA1's are computed--maybe this\nisn't feasible.)\n\nMike\n"},{"id":"34810","messageId":"alpine.LRH.0.82.0702161136460.18370@xanadu.home","threadId":"6847","inReplyTo":"3c6c07c20702160823j316c52f4pe4cf5ca8a882e194@mail.gmail.com","subject":"Re: suggested feature: someone mails me a blob, git please tell me what it is","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-02-16T16:48:46Z","receivedAt":"2007-02-16T16:48:46Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Fri, 16 Feb 2007, Mike Coleman wrote:\n\n> Here's a suggestion for a git feature, if git doesn't already have it.\n> Since git generally doesn't use RCS-style keyword cookies (like\n> \"$Id$\"), it'd be nice to have some other way to identify an installed\n> file.  Perhaps you'd want to know exactly what rev a user is running,\n> for example.\n> \n> It seems like it should be fairly easy, given a blob (the file), for\n> git to describe what it knows about it.  For example, it could provide\n> a list of commits that it's a part of, etc.  \n\nThat is possible, but would be expensive similar to git-fsck-objects.  \nAll objects for each commit would need to be searched for the matching \nsha1.\n\n> It'd be *really* nice if only the output of the sha1sum command on the \n> blob were needed.  (I can't recall exactly how git's blob SHA1's are \n> computed--maybe this isn't feasible.)\n\nGIT adds a header of its own before object data.  You therefore need to \nuse git-hash-object not sha1sum to get the right sha1 value.\n\n\nNicolas\n"},{"id":"34813","messageId":"vpqr6sq58j8.fsf@olympe.imag.fr","threadId":"6847","inReplyTo":"3c6c07c20702160823j316c52f4pe4cf5ca8a882e194@mail.gmail.com","subject":"Re: suggested feature: someone mails me a blob, git please tell me what it is","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-02-16T17:14:51Z","receivedAt":"2007-02-16T17:14:51Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"\"Mike Coleman\" <tutufan@gmail.com> writes:\n\n> It seems like it should be fairly easy, given a blob (the file), for\n> git to describe what it knows about it.  For example, it could provide\n> a list of commits that it's a part of, etc.  It'd be *really* nice if\n> only the output of the sha1sum command on the blob were needed. \n\n\"git cat-file -p\" does almost this : given the sha1sum for a blob, it\nwill give the header and the content of the blob ...\n\n> (I can't recall exactly how git's blob SHA1's are computed--maybe\n> this isn't feasible.)\n\n... but this is where it doesn't work :\nhttp://www.kernel.org/pub/software/scm/git/docs/v1.5.0/git.html#Discussion\nexplains that the sha1sum used by git is the one of the blob _plus_\nits header, so it's not the one you get with \"sha1sum file\".\n\nBut it should be possible to recompute the git sha1sum by recomputing\nthe magic formula sha1sum(<ascii type without space> + <space> +\n<ascii decimal size> + <byte\\0> + <binary object data>).\n\n-- \nMatthieu\n"},{"id":"34814","messageId":"Pine.LNX.4.64.0702160930130.20368@woody.linux-foundation.org","threadId":"6847","inReplyTo":"vpqr6sq58j8.fsf@olympe.imag.fr","subject":"Re: suggested feature: someone mails me a blob, git please tell me what it is","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-02-16T17:37:55Z","receivedAt":"2007-02-16T17:37:55Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 16 Feb 2007, Matthieu Moy wrote:\n> \n> But it should be possible to recompute the git sha1sum by recomputing\n> the magic formula sha1sum(<ascii type without space> + <space> +\n> <ascii decimal size> + <byte\\0> + <binary object data>).\n\nYes. Try this:\n\n\t[torvalds@woody git]$ ls -l Makefile\n\t-rw-rw-rw- 1 torvalds torvalds 27586 Feb 14 13:35 Makefile\n\t[torvalds@woody git]$ ( echo -en \"blob 27586\\0\" ; cat Makefile ) | sha1sum\n\tebecbbd9c28390654ed9fea2ff4ebf6a5a317c70  -\n\n\t[torvalds@woody git]$ git ls-tree HEAD Makefile\n\t100644 blob ebecbbd9c28390654ed9fea2ff4ebf6a5a317c70    Makefile\n\nand notice how the SHA1's match (ebecbb..).\n\nNow, finding all of the copies of that particular object in history is \npretty expensive. You'll basically have to do something like\n\n\tgit rev-list --all |\n\t\twhile read i\n\t\tdo\n\t\t\tfiles=$(git ls-tree -r $i | grep $SHA1)\n\t\t\tif [ -n \"$files\" ]\n\t\t\tthen\n\t\t\t\tgit cat-file -p $i\n\t\t\t\techo $files\n\t\t\t\techo\n\t\t\tfi\n\t\tdone\n\nwhich is quite expensive. You can probably start from \"git fsck\" and ask \nit to print out where it found something (but then it will print out only \nthe first time it found it - because it avoids walking trees more than \nonce it won't report on it unless if finds it in two trees that are \ndifferent).\n\n\t\t\tLinus\n"},{"id":"34846","messageId":"20070217061016.GA27813@spearce.org","threadId":"6847","inReplyTo":"3c6c07c20702160823j316c52f4pe4cf5ca8a882e194@mail.gmail.com","subject":"Re: suggested feature: someone mails me a blob, git please tell me what it is","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-02-17T06:10:16Z","receivedAt":"2007-02-17T06:10:16Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Mike Coleman <tutufan@gmail.com> wrote:\n> Here's a suggestion for a git feature, if git doesn't already have it.\n> Since git generally doesn't use RCS-style keyword cookies (like\n> \"$Id$\"), it'd be nice to have some other way to identify an installed\n> file.  Perhaps you'd want to know exactly what rev a user is running,\n> for example.\n> \n> It seems like it should be fairly easy, given a blob (the file), for\n> git to describe what it knows about it.  For example, it could provide\n> a list of commits that it's a part of, etc.  It'd be *really* nice if\n> only the output of the sha1sum command on the blob were needed.  (I\n> can't recall exactly how git's blob SHA1's are computed--maybe this\n> isn't feasible.)\n\nRather than embedding something like \"$Id$\" on a per-file basis\nuse the output of git-describe in your build process to insert the\nstring into your executable file(s), and then provide a way to let\nthe user extract it, or insert it with a unique enough pattern that\nyou can grep for it in the output of `strings`.\n\nThis is what git does itself.  We replace GIT_VERSION in git.c\nwith the output of git-describe during compile time (C preprocessor\nmacro).  The value can be printed by the user with `git version`.\nWe also embed it into some Perl scripts.\n\ngit-gui does the same thing, but is a Tcl/Tk script.\n\n-- \nShawn.\n"},{"id":"34895","messageId":"200702172140.54203.andyparkins@gmail.com","threadId":"6847","inReplyTo":"20070217061016.GA27813@spearce.org","subject":"Re: suggested feature: someone mails me a blob, git please tell me what it is","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-02-17T21:40:51Z","receivedAt":"2007-02-17T21:40:51Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Saturday 2007, February 17, Shawn O. Pearce wrote:\n\n> Rather than embedding something like \"$Id$\" on a per-file basis\n> use the output of git-describe in your build process to insert the\n\nActually this isn't entirely enough.  The /only/ thing I miss from \nsubversion is $Id$; but not in source files - that's easily solved with \na bit of git-describe magic in the Makefile - no, I miss embedding it \ninkscape generated .svg files, so that my title block on diagrams gets \nautomatically assigned a version code.\n\nQ: How lazy am I?  A: I can't be bothered to say... \n\nAndy\n\n-- \nDr Andrew Parkins, M Eng (Hons), AMIEE\nandyparkins@gmail.com\n"}]}