git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: current repository hash

From
DTDavid Tweed <david.tweed@gmail.com>
Date
Jun 16, 2008, 12:11 UTC
Message-ID
<e1dab3980806160511s1a9a5192gbdf6539205ef1865@mail.gmail.com>
In-Reply-To
<556d90580806160451g36daefb6o48b93b92589211bf@mail.gmail.com>
On Mon, Jun 16, 2008 at 12:51 PM, Alf Clement <alf.clement@gmail.com> wrote:
> What would be the best command to get a unique identifier?

Note that git itself does this via the GIT-VERSION-GEN script so you could look at that for ideas.

> How can I make sure that a shorter hash id will be unique?

Theoretically isn't that going to be tricky, as you don't just want something that's unique at the time you compile the program but which won't potentially be rendered non-unique by later commits (after you've released your binary)? If you just want to be reasonably sure you can truncate the hash to the length you'd like, eg "addcc13a" for 8 characters and run

git rev-parse addcc13a
and see if it says

addcc13a fatal: ambiguous argument 'addcc13a': unknown revision or path not in the working tree. Use '--' to separate paths from revisions

-- 
cheers, dave tweed__________________________
david.tweed@gmail.com
Rm 124, School of Systems Engineering, University of Reading.
"while having code so boring anyone can maintain it, use Python." --
attempted insult seen on slashdot
Previous: Alf ClementNext: Santi Béjar
Message 2 of 9 in “current repository hash”
  1. Alf ClementJun 16, 2008
  2. David TweedJun 16, 2008
  3. Santi BéjarJun 16, 2008
  4. Alf ClementJun 16, 2008
  5. Jeff KingJun 16, 2008
  6. Alf ClementJun 17, 2008
  7. Johan HerlandJun 17, 2008
  8. Jeff KingJun 16, 2008
  9. Johannes SchindelinJun 17, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.