Git development
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: stoecher@gmx.at
Cc: git@vger.kernel.org
Subject: Re: just curious: what influences a commit hash?
Date: Thu, 05 Mar 2009 11:38:08 +0100	[thread overview]
Message-ID: <vpq7i3445m7.fsf@bauges.imag.fr> (raw)
In-Reply-To: <20090305063632.42880@gmx.net> (stoecher@gmx.at's message of "Thu\, 05 Mar 2009 07\:36\:32 +0100")

stoecher@gmx.at writes:

> Hi,
>
> being new to git I did some experiments with commits looking at the hashes. What I observed:
> * The same commit (same file, same committer, same message) into
> different empty repositories (git init) gives different hashes. So I
> assume that also the time of the commit influences the hash. Is this
> intended? For what reason?

You should distinguish "commit objects" from "tree objects". You can
see the "commit" object with, for example:

$ git cat-file -p HEAD
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
author Matthieu Moy <Matthieu.Moy@imag.fr> 1236249249 +0100
committer Matthieu Moy <Matthieu.Moy@imag.fr> 1236249249 +0100

foo

See: it contains a reference to the tree, possibly references to the
parents, and a timestamp. So, hashing it takes the timestamp into
account. A consequence of this is that you can not change the
timestamp for a commit without changing the "revision identifier"
(i.e. the hash of the commit object).

But the empty tree object is deterministically
4b825dc642cb6eb9a060e54bf8d69288fbee4904.

-- 
Matthieu

      parent reply	other threads:[~2009-03-05 10:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-05  6:36 just curious: what influences a commit hash? stoecher
2009-03-05  7:25 ` Matt Enright
2009-03-05  9:02   ` Uwe Kleine-König
2009-03-05 10:38 ` Matthieu Moy [this message]

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=vpq7i3445m7.fsf@bauges.imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=stoecher@gmx.at \
    /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