Merge branch 'bc/t3430-fixup'
authorJunio C Hamano <gitster@pobox.com>
Mon, 4 Jun 2018 12:39:50 +0000 (21:39 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 4 Jun 2018 12:39:50 +0000 (21:39 +0900)
Test fix.

* bc/t3430-fixup:
t3430: test clean-up

1  2 
t/t3430-rebase-merges.sh
diff --combined t/t3430-rebase-merges.sh
index 2608e5483d5268f4b84f726b7b2d54961ee76a27,9fc4648ff8a8e84c772e8f4334b7b2a65df12f22..78f7c9958030bee8d8040eda0380ba5af16d0441
@@@ -70,7 -70,6 +70,6 @@@ test_expect_success 'create completely 
        merge -C H second
        merge onebranch # Merge the topic branch '\''onebranch'\''
        EOF
-       cp script-from-scratch script-from-scratch-orig &&
        test_config sequence.editor \""$PWD"/replace-editor.sh\" &&
        test_tick &&
        git rebase -i -r A &&
@@@ -242,91 -241,19 +241,91 @@@ test_expect_success 'refuse to merge an
        test_cmp_rev HEAD $before
  '
  
 +test_expect_success 'root commits' '
 +      git checkout --orphan unrelated &&
 +      (GIT_AUTHOR_NAME="Parsnip" GIT_AUTHOR_EMAIL="root@example.com" \
 +       test_commit second-root) &&
 +      test_commit third-root &&
 +      cat >script-from-scratch <<-\EOF &&
 +      pick third-root
 +      label first-branch
 +      reset [new root]
 +      pick second-root
 +      merge first-branch # Merge the 3rd root
 +      EOF
 +      test_config sequence.editor \""$PWD"/replace-editor.sh\" &&
 +      test_tick &&
 +      git rebase -i --force --root -r &&
 +      test "Parsnip" = "$(git show -s --format=%an HEAD^)" &&
 +      test $(git rev-parse second-root^0) != $(git rev-parse HEAD^) &&
 +      test $(git rev-parse second-root:second-root.t) = \
 +              $(git rev-parse HEAD^:second-root.t) &&
 +      test_cmp_graph HEAD <<-\EOF &&
 +      *   Merge the 3rd root
 +      |\
 +      | * third-root
 +      * second-root
 +      EOF
 +
 +      : fast forward if possible &&
 +      before="$(git rev-parse --verify HEAD)" &&
 +      test_might_fail git config --unset sequence.editor &&
 +      test_tick &&
 +      git rebase -i --root -r &&
 +      test_cmp_rev HEAD $before
 +'
 +
 +test_expect_success 'a "merge" into a root commit is a fast-forward' '
 +      head=$(git rev-parse HEAD) &&
 +      cat >script-from-scratch <<-EOF &&
 +      reset [new root]
 +      merge $head
 +      EOF
 +      test_config sequence.editor \""$PWD"/replace-editor.sh\" &&
 +      test_tick &&
 +      git rebase -i -r HEAD^ &&
 +      test_cmp_rev HEAD $head
 +'
 +
 +test_expect_success 'A root commit can be a cousin, treat it that way' '
 +      git checkout --orphan khnum &&
 +      test_commit yama &&
 +      git checkout -b asherah master &&
 +      test_commit shamkat &&
 +      git merge --allow-unrelated-histories khnum &&
 +      test_tick &&
 +      git rebase -f -r HEAD^ &&
 +      ! test_cmp_rev HEAD^2 khnum &&
 +      test_cmp_graph HEAD^.. <<-\EOF &&
 +      *   Merge branch '\''khnum'\'' into asherah
 +      |\
 +      | * yama
 +      o shamkat
 +      EOF
 +      test_tick &&
 +      git rebase --rebase-merges=rebase-cousins HEAD^ &&
 +      test_cmp_graph HEAD^.. <<-\EOF
 +      *   Merge branch '\''khnum'\'' into asherah
 +      |\
 +      | * yama
 +      |/
 +      o shamkat
 +      EOF
 +'
 +
  test_expect_success 'labels that are object IDs are rewritten' '
        git checkout -b third B &&
-       test_tick &&
        test_commit I &&
        third=$(git rev-parse HEAD) &&
        git checkout -b labels master &&
        git merge --no-commit third &&
        test_tick &&
        git commit -m "Merge commit '\''$third'\'' into labels" &&
-       cp script-from-scratch-orig script-from-scratch &&
+       echo noop >script-from-scratch &&
        test_config sequence.editor \""$PWD"/replace-editor.sh\" &&
        test_tick &&
        git rebase -i -r A &&
+       grep "^label $third-" .git/ORIGINAL-TODO &&
        ! grep "^label $third$" .git/ORIGINAL-TODO
  '