git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git merge commits are non-deterministic? what changed?

From
USUlrich Spörlein <uqs@spoerlein.net>
Date
Nov 9, 2012, 13:31 UTC
Message-ID
<20121109133132.GK69724@acme.spoerlein.net>
Hi all,

I'm running a couple of conversions from SVN to git, using a slightly hacked version of svn2git (because it can cope with multiple branches and is several orders of magnitude faster than git-svn).

Anyway, when doing some verification runs, using the same version of svn2git, but different versions of git, I get different commit hashes, and I tracked it down to the ordering of the parents inside a merge commit.

version 1.7.9.2 % git show --format=raw e209a83|head commit e209a83c1e0a387c88a44f3a8f2be2670ed85eae tree de2d7c6726a45428d4a310da2acd8839daf9f85f parent 5fba0401c23a594e4ad5e807bf14a5439645a358 parent 25062ba061871945759b3baa833fe64969383e40 parent 89bebeef185ed08424fc548f8569081c6add2439 parent c7d5f60d3a7e2e3c4da23b157c62504667344438 parent e7bc108f0d6a394050818a4af64a59094d3c793e parent 48231afadc40013e6bfda56b04a11ee3a602598f author rgrimes <rgrimes@FreeBSD.org> 739897097 +0000 committer rgrimes <rgrimes@FreeBSD.org> 739897097 +0000

vs

git version 1.8.0 % git show --format=raw 42f0fad|head commit 42f0fadccab6eefc7ffdc1012345b42ad45e36c2 tree de2d7c6726a45428d4a310da2acd8839daf9f85f parent 5fba0401c23a594e4ad5e807bf14a5439645a358 parent 25062ba061871945759b3baa833fe64969383e40 parent 89bebeef185ed08424fc548f8569081c6add2439 parent 48231afadc40013e6bfda56b04a11ee3a602598f parent c7d5f60d3a7e2e3c4da23b157c62504667344438 parent e7bc108f0d6a394050818a4af64a59094d3c793e author rgrimes <rgrimes@FreeBSD.org> 739897097 +0000 committer rgrimes <rgrimes@FreeBSD.org> 739897097 +0000

I haven't verified to see if that ordering is stable within a git version, but the fact that it changed across versions clearly means that I cannot depend on this currently (I have never seen this problem in two years, so I blame git 1.8.0 ...)

Two questions:
1. Can we impose a stable ordering of the commits being recorded in a
merge commit? Listing parents in chronological order or something like
that.
2. Why the hell is the commit hash dependent on the ordering of the
parent commits? IMHO it should sort the set of parents before
calculating the hash ...

Help? Uli

Next: Andreas Schwab
Message 1 of 9 in “git merge commits are non-deterministic? what changed?”
  1. Ulrich SpörleinNov 9, 2012
  2. Andreas SchwabNov 9, 2012
  3. Ulrich SpörleinNov 9, 2012
  4. Matthieu MoyNov 9, 2012
  5. Jeff KingNov 9, 2012
  6. Ulrich SpörleinNov 9, 2012
  7. Michael J GruberNov 12, 2012
  8. Ulrich SpörleinNov 20, 2012
  9. Junio C HamanoNov 20, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.