lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Unexpected difference in git sha1sums


From: Vadim Zeitlin
Subject: Re: [lmi] Unexpected difference in git sha1sums
Date: Thu, 3 Mar 2016 22:28:45 +0100

On Thu, 3 Mar 2016 21:00:13 +0000 Greg Chicares <address@hidden> wrote:

GC> If I have two git repositories (one Cygwin, one GNU/Linux) that have
GC> the same HEAD sha1sum, and I run 'git am' to apply the same patch to
GC> each (verified by identical md5sums of the patch file), then shouldn't
GC> I have the same commit sha1sum and the same new HEAD sha1sum on both?

 Sorry, I think that I had myself mistakenly said that it should be the
same in the past, but this is not the case because "git am" uses the time
of the commit as one of the inputs to generate the hash and the time is
different in the two cases.

 You could get rid of this difference by using the same, fixed timestamp
for both commits, e.g.

        $ GIT_COMMITTER_DATE=1457040000 git am ...

(you have, of course, recognized this timestamp as 2016-03-03T21:20:00Z
but Git is so user-friendly that it even allows you to use other formats:
https://www.kernel.org/pub/software/scm/git/docs/git-commit.html#_date_formats)

 I don't know if this is really going to be convenient for you as you will
have to be careful to use the write (or at least the same) timestamp every
time and if you make a mistake, the command will still work -- but the
repositories would diverge. Maybe "git bundle" is a better solution,
finally (it's definitely a more compact one, especially for the XML files).

 But wait, I discovered something I didn't know about Git just now: "git
am" has a --committer-date-is-author-date option which, I think, should
also work and create the same commit SHA-1 sums. It seems to work too in my
testing and is less error-prone than specifying GIT_COMMITTER_DATE manually,
so finally I think this is the simplest solution.

 Regards,
VZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]