All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Enright <awickedshimmy@gmail.com>
To: stoecher@gmx.at
Cc: git@vger.kernel.org
Subject: Re: just curious: what influences a commit hash?
Date: Thu, 05 Mar 2009 02:25:39 -0500	[thread overview]
Message-ID: <1236237939.2421.38.camel@virgil> (raw)
In-Reply-To: <20090305063632.42880@gmx.net>

[-- Attachment #1: Type: text/plain, Size: 1458 bytes --]

On Thu, 2009-03-05 at 07:36 +0100, stoecher@gmx.at wrote:
> 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?
> * Having created two repositories exactly the same way (the history is the same except for the commit times and hashes) I applied the same patch (using git am) and again I got different hashes for these commits. So in some way also the repository/branch influences the hash of a commit!?

This should be expected if the initial hashes in the history are
different. The hash of a commit is based also on the hashes of all
parent commits - in this way git 'protects' the repository history by
guaranteeing that if two objects have the same hash, they will come from
the same history.
So the second issue is a consequence of the first, though I am not
certain why the first occurs (if the file contents and size are the
same, I would expect the hash for the blob/tree to be the same - maybe
due to git's special handling of initial commits?)

> From reading the Git user's manual, chapter 10, object storage format, I was not expecting this. Can someone explain or give a link to a more detailed description?
> 
> thank you,
> 
> Wolfgang
> 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2009-03-05  7:28 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 [this message]
2009-03-05  9:02   ` Uwe Kleine-König
2009-03-05 10:38 ` Matthieu Moy

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=1236237939.2421.38.camel@virgil \
    --to=awickedshimmy@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.