git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Santi Béjar" <sbejar@gmail.com>
To: "Alf Clement" <alf.clement@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: current repository hash
Date: Mon, 16 Jun 2008 14:15:14 +0200	[thread overview]
Message-ID: <8aa486160806160515p751b2af4j2b0db6db7a9ad482@mail.gmail.com> (raw)
In-Reply-To: <556d90580806160451g36daefb6o48b93b92589211bf@mail.gmail.com>

On Mon, Jun 16, 2008 at 13:51, Alf Clement <alf.clement@gmail.com> wrote:
> Hi all,
>
> I want to compile the current repository hash id into my program, to
> be able to checkout later this
> id an see the exact files for the compile. It should flag if there are
> currently modified files in the
> directory tree.

You can look at how git does it:

http://git.kernel.org/?p=git/git.git;a=blob;f=GIT-VERSION-GEN;hb=HEAD

>
> What would be the best command to get a unique identifier?

"git rev-parse HEAD" for a unique identifier,
but "git describe" is more convenient/useful.

> Do I need the 40 digit hash id?

Normally 7 or 8 are sufficient.

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

You can't. Even the 40 digit hash is "only" cryptographically unique.
But within a project 7 or 8 digits are unique enough for practical
use.

Santi

  parent reply	other threads:[~2008-06-16 12:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-16 11:51 current repository hash Alf Clement
2008-06-16 12:11 ` David Tweed
2008-06-16 12:15 ` Santi Béjar [this message]
2008-06-16 18:30   ` Alf Clement
2008-06-16 18:45     ` Jeff King
2008-06-17  6:48       ` Alf Clement
2008-06-17  7:07         ` Johan Herland
2008-06-16 15:04 ` Jeff King
2008-06-17  9:51 ` Johannes Schindelin

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=8aa486160806160515p751b2af4j2b0db6db7a9ad482@mail.gmail.com \
    --to=sbejar@gmail.com \
    --cc=alf.clement@gmail.com \
    --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).