{"thread":{"id":"13978","subject":"current repository hash","startedAt":"2008-06-16T11:51:52Z","lastAt":"2008-06-17T09:51:32Z","messageCount":9,"participants":["Alf Clement","David Tweed","Santi Béjar","Jeff King","Johan Herland","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"80022","messageId":"556d90580806160451g36daefb6o48b93b92589211bf@mail.gmail.com","threadId":"13978","inReplyTo":null,"subject":"current repository hash","fromName":"Alf Clement","fromEmail":"alf.clement@gmail.com","sentAt":"2008-06-16T11:51:52Z","receivedAt":"2008-06-16T11:51:52Z","isPatch":false,"sender":{"key":"alf.clement@gmail.com","avatar":null},"body":"Hi all,\n\nI want to compile the current repository hash id into my program, to\nbe able to checkout later this\nid an see the exact files for the compile. It should flag if there are\ncurrently modified files in the\ndirectory tree.\n\nWhat would be the best command to get a unique identifier?\nDo I need the 40 digit hash id?\nHow can I make sure that a shorter hash id will be unique?\n\nThanks,\nAlf\n"},{"id":"80023","messageId":"e1dab3980806160511s1a9a5192gbdf6539205ef1865@mail.gmail.com","threadId":"13978","inReplyTo":"556d90580806160451g36daefb6o48b93b92589211bf@mail.gmail.com","subject":"Re: current repository hash","fromName":"David Tweed","fromEmail":"david.tweed@gmail.com","sentAt":"2008-06-16T12:11:46Z","receivedAt":"2008-06-16T12:11:46Z","isPatch":false,"sender":{"key":"david.tweed@gmail.com","avatar":null},"body":"On Mon, Jun 16, 2008 at 12:51 PM, Alf Clement <alf.clement@gmail.com> wrote:\n> What would be the best command to get a unique identifier?\n\nNote that git itself does this via the GIT-VERSION-GEN script so you\ncould look at that for ideas.\n\n> How can I make sure that a shorter hash id will be unique?\n\nTheoretically isn't that going to be tricky, as you don't just want\nsomething that's unique at the time you compile the program but which\nwon't potentially be rendered non-unique by later commits (after\nyou've released your binary)? If you just want to be reasonably sure\nyou can truncate the hash to the length you'd like, eg \"addcc13a\" for\n8 characters and run\n\ngit rev-parse addcc13a\n\nand see if it says\n\naddcc13a\nfatal: ambiguous argument 'addcc13a': unknown revision or path not in\nthe working tree.\nUse '--' to separate paths from revisions\n\n-- \ncheers, dave tweed__________________________\ndavid.tweed@gmail.com\nRm 124, School of Systems Engineering, University of Reading.\n\"while having code so boring anyone can maintain it, use Python.\" --\nattempted insult seen on slashdot\n"},{"id":"80024","messageId":"8aa486160806160515p751b2af4j2b0db6db7a9ad482@mail.gmail.com","threadId":"13978","inReplyTo":"556d90580806160451g36daefb6o48b93b92589211bf@mail.gmail.com","subject":"Re: current repository hash","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-06-16T12:15:14Z","receivedAt":"2008-06-16T12:15:14Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Mon, Jun 16, 2008 at 13:51, Alf Clement <alf.clement@gmail.com> wrote:\n> Hi all,\n>\n> I want to compile the current repository hash id into my program, to\n> be able to checkout later this\n> id an see the exact files for the compile. It should flag if there are\n> currently modified files in the\n> directory tree.\n\nYou can look at how git does it:\n\nhttp://git.kernel.org/?p=git/git.git;a=blob;f=GIT-VERSION-GEN;hb=HEAD\n\n>\n> What would be the best command to get a unique identifier?\n\n\"git rev-parse HEAD\" for a unique identifier,\nbut \"git describe\" is more convenient/useful.\n\n> Do I need the 40 digit hash id?\n\nNormally 7 or 8 are sufficient.\n\n> How can I make sure that a shorter hash id will be unique?\n\nYou can't. Even the 40 digit hash is \"only\" cryptographically unique.\nBut within a project 7 or 8 digits are unique enough for practical\nuse.\n\nSanti\n"},{"id":"80031","messageId":"20080616150416.GA6164@sigill.intra.peff.net","threadId":"13978","inReplyTo":"556d90580806160451g36daefb6o48b93b92589211bf@mail.gmail.com","subject":"Re: current repository hash","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-06-16T15:04:17Z","receivedAt":"2008-06-16T15:04:17Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 16, 2008 at 01:51:52PM +0200, Alf Clement wrote:\n\n> What would be the best command to get a unique identifier?\n\nIf you just want the commit sha1, then \"git rev-list -1 HEAD\" will give\nit to you. But take a look at git-describe, which is designed to give a\nnice human-readable name based on your tags.\n\n> Do I need the 40 digit hash id?\n\nNo, but you increase your chances of a collision in the future. In\npractice, 8 or 9 characters tends to give unique commits.\n\n> How can I make sure that a shorter hash id will be unique?\n\ngit-describe will find the shortest unique hash. But bear in mind that\nit may not be unique forever.\n\n-Peff\n"},{"id":"80053","messageId":"556d90580806161130g62269318i46f00e5c7f79b7d9@mail.gmail.com","threadId":"13978","inReplyTo":"8aa486160806160515p751b2af4j2b0db6db7a9ad482@mail.gmail.com","subject":"Re: current repository hash","fromName":"Alf Clement","fromEmail":"alf.clement@gmail.com","sentAt":"2008-06-16T18:30:16Z","receivedAt":"2008-06-16T18:30:16Z","isPatch":false,"sender":{"key":"alf.clement@gmail.com","avatar":null},"body":"Hi all,\n\nthanks for the tips.\n\nWhen I run describe I get an error:\n$ git describe --debug HEAD\nfatal: cannot describe '792815de6e3c2403f1e2ed5f2264ca88a0ae7000'\n\nAny hints why? I have a tag v1.3 attached to HEAD and all commited.\n\nCU,\nAlf\n\nOn Mon, Jun 16, 2008 at 2:15 PM, Santi Béjar <sbejar@gmail.com> wrote:\n> On Mon, Jun 16, 2008 at 13:51, Alf Clement <alf.clement@gmail.com> wrote:\n>> Hi all,\n>>\n>> I want to compile the current repository hash id into my program, to\n>> be able to checkout later this\n>> id an see the exact files for the compile. It should flag if there are\n>> currently modified files in the\n>> directory tree.\n>\n> You can look at how git does it:\n>\n> http://git.kernel.org/?p=git/git.git;a=blob;f=GIT-VERSION-GEN;hb=HEAD\n>\n>>\n>> What would be the best command to get a unique identifier?\n>\n> \"git rev-parse HEAD\" for a unique identifier,\n> but \"git describe\" is more convenient/useful.\n>\n>> Do I need the 40 digit hash id?\n>\n> Normally 7 or 8 are sufficient.\n>\n>> How can I make sure that a shorter hash id will be unique?\n>\n> You can't. Even the 40 digit hash is \"only\" cryptographically unique.\n> But within a project 7 or 8 digits are unique enough for practical\n> use.\n>\n> Santi\n>\n"},{"id":"80054","messageId":"20080616184520.GA11992@sigill.intra.peff.net","threadId":"13978","inReplyTo":"556d90580806161130g62269318i46f00e5c7f79b7d9@mail.gmail.com","subject":"Re: current repository hash","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-06-16T18:45:20Z","receivedAt":"2008-06-16T18:45:20Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 16, 2008 at 08:30:16PM +0200, Alf Clement wrote:\n\n> When I run describe I get an error:\n> $ git describe --debug HEAD\n> fatal: cannot describe '792815de6e3c2403f1e2ed5f2264ca88a0ae7000'\n> \n> Any hints why? I have a tag v1.3 attached to HEAD and all commited.\n\nBy default, git-describe uses only annotated tags. Try \"git describe\n--tags HEAD\".\n\n-Peff\n"},{"id":"80105","messageId":"556d90580806162348q6c6b90daoe48c3fa330f488ec@mail.gmail.com","threadId":"13978","inReplyTo":"20080616184520.GA11992@sigill.intra.peff.net","subject":"Re: current repository hash","fromName":"Alf Clement","fromEmail":"alf.clement@gmail.com","sentAt":"2008-06-17T06:48:01Z","receivedAt":"2008-06-17T06:48:01Z","isPatch":false,"sender":{"key":"alf.clement@gmail.com","avatar":null},"body":"Hi all,\n\nwhen I run\n   $ git describe --tags HEAD\non my branch \"fire1\", I get:\n    v1.5-13-g27f64b3\n\nI wonder why it's -13. The last action I did was to merge the master branch,\nwhich has the v1.5 tag. So it should be much less than 13?\nA snapshot from gitk is attached.\n\nCU,\nAlf\n"},{"id":"80109","messageId":"200806170907.39665.johan@herland.net","threadId":"13978","inReplyTo":"556d90580806162348q6c6b90daoe48c3fa330f488ec@mail.gmail.com","subject":"Re: current repository hash","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-06-17T07:07:39Z","receivedAt":"2008-06-17T07:07:39Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Tuesday 17 June 2008, Alf Clement wrote:\n> Hi all,\n>\n> when I run\n>    $ git describe --tags HEAD\n> on my branch \"fire1\", I get:\n>     v1.5-13-g27f64b3\n>\n> I wonder why it's -13. The last action I did was to merge the master\n> branch, which has the v1.5 tag. So it should be much less than 13?\n> A snapshot from gitk is attached.\n>\n> CU,\n> Alf\n\nAFAICS from your graph there are exactly 13 commits that are part of fire1, \nbut not part of v.1.5 (from the bottom of the graph):\n- \"fire 1       modified: main.c\"\n- The 8 commits on a parallel branch leading towards origin/fire1\n- The origin/fire1 merge\n- The 4th last commit: \"Merge branch 'master' into fire1\"\n- The 3rd last commit: \"modified: main.c\"\n- The very last commit: fire1\n\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"80122","messageId":"alpine.DEB.1.00.0806171050440.6439@racer","threadId":"13978","inReplyTo":"556d90580806160451g36daefb6o48b93b92589211bf@mail.gmail.com","subject":"Re: current repository hash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-06-17T09:51:32Z","receivedAt":"2008-06-17T09:51:32Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 16 Jun 2008, Alf Clement wrote:\n\n> I want to compile the current repository hash id into my program, to be \n> able to checkout later this id an see the exact files for the compile.\n\nIf this program is meant for source-distribution, you might be interested \nin the \"export-subst\" attribute.  See Documentation/gitattributes.txt for \ndetails.\n\nCiao,\nDscho\n"}]}