Thread (1 message) 1 message, 1 author, 2016-06-15

Re: just curious: what influences a commit hash?

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:46:20

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 [off-list ref] 1236249249 +0100
committer Matthieu Moy [off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help