threads / discuss / 48521

Fun puzzle: successful merge's contents depends on...commit timestamps?

Subject: Fun puzzle: successful merge's contents depends on...commit timestamps?

## tl;dr

One message between May 19, 2018 and May 19, 2018.

replies: 0people: 1as markdown or json

Elijah Newren· May 19, 2018, 03:07 UTC · lore
Check this out; I merge another branch successfully:
  $ git merge -m F $othersha; echo $?
  0
This is just a simple test repo:
  $ git log --oneline
  18f5e65 (HEAD -> master) F
  7472b46 E
  ea0d801 D
  4486f96 C
  7727e3b B
  ee47c13 A
Below it is important to note that one commit was made at 1526194997,
and this value doesn't appear anywhere else in fast-export output:
  $ git fast-export --no-data master | grep 1526194997
  author Elijah Newren <newren@gmail.com> 1526194997 -0700
  committer Elijah Newren <newren@gmail.com> 1526194997 -0700
Let's create a new branch and rewrite history ONLY changing that one timestamp:
  $ git checkout -b redo
  $ git fast-export --no-data redo | \
       sed -e s/1526194997/1500000000/ | \
       git fast-import --quiet --force
At this point, the trees for 'master' and 'redo' match, as you'd expect:
  $ git diff --quiet master HEAD; echo $?
  0
Let's redo that merge, shall we?:
  $ git checkout --quiet 'redo^1'
  $ git merge -m newF 'redo^2'; echo $?
  $ 0
Did we get the same merge result?  Nope:
  $ git diff --quiet master HEAD; echo $?
  1

I believe there are about half a dozen solutions to this puzzle. Can you find at least one?

← back to recent threads