Merge branch 'jk/am-i-resolved-fix'
[gitweb.git] / t / t7600-merge.sh
index 2f4c2801fb8014c04a95fb04912f0a3bda55d11b..612ebe7d8289d10fe35a72945b5991dca169c1c2 100755 (executable)
@@ -246,6 +246,52 @@ test_expect_success 'merge --squash c3 with c7' '
        test_cmp expect actual
 '
 
+test_expect_success 'merge c3 with c7 with commit.cleanup = scissors' '
+       git config commit.cleanup scissors &&
+       git reset --hard c3 &&
+       test_must_fail git merge c7 &&
+       cat result.9z >file &&
+       git commit --no-edit -a &&
+
+       cat >expect <<-\EOF &&
+       Merge tag '"'"'c7'"'"'
+
+       # ------------------------ >8 ------------------------
+       # Do not modify or remove the line above.
+       # Everything below it will be ignored.
+       #
+       # Conflicts:
+       #       file
+       EOF
+       git cat-file commit HEAD >raw &&
+       sed -e '1,/^$/d' raw >actual &&
+       test_i18ncmp expect actual
+'
+
+test_expect_success 'merge c3 with c7 with --squash commit.cleanup = scissors' '
+       git config commit.cleanup scissors &&
+       git reset --hard c3 &&
+       test_must_fail git merge --squash c7 &&
+       cat result.9z >file &&
+       git commit --no-edit -a &&
+
+       cat >expect <<-EOF &&
+       Squashed commit of the following:
+
+       $(git show -s c7)
+
+       # ------------------------ >8 ------------------------
+       # Do not modify or remove the line above.
+       # Everything below it will be ignored.
+       #
+       # Conflicts:
+       #       file
+       EOF
+       git cat-file commit HEAD >raw &&
+       sed -e '1,/^$/d' raw >actual &&
+       test_i18ncmp expect actual
+'
+
 test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c1 with c2 and c3' '
@@ -821,4 +867,50 @@ test_expect_success EXECKEEPSPID 'killed merge can be completed with --continue'
        verify_parents $c0 $c1
 '
 
+test_expect_success 'merge --quit' '
+       git init merge-quit &&
+       (
+               cd merge-quit &&
+               test_commit base &&
+               echo one >>base.t &&
+               git commit -am one &&
+               git branch one &&
+               git checkout base &&
+               echo two >>base.t &&
+               git commit -am two &&
+               test_must_fail git -c rerere.enabled=true merge one &&
+               test_path_is_file .git/MERGE_HEAD &&
+               test_path_is_file .git/MERGE_MODE &&
+               test_path_is_file .git/MERGE_MSG &&
+               git rerere status >rerere.before &&
+               git merge --quit &&
+               test_path_is_missing .git/MERGE_HEAD &&
+               test_path_is_missing .git/MERGE_MODE &&
+               test_path_is_missing .git/MERGE_MSG &&
+               git rerere status >rerere.after &&
+               test_must_be_empty rerere.after &&
+               ! test_cmp rerere.after rerere.before
+       )
+'
+
+test_expect_success 'merge suggests matching remote refname' '
+       git commit --allow-empty -m not-local &&
+       git update-ref refs/remotes/origin/not-local HEAD &&
+       git reset --hard HEAD^ &&
+
+       # This is white-box testing hackery; we happen to know
+       # that reading packed refs is more picky about the memory
+       # ownership of strings we pass to for_each_ref() callbacks.
+       git pack-refs --all --prune &&
+
+       test_must_fail git merge not-local 2>stderr &&
+       grep origin/not-local stderr
+'
+
+test_expect_success 'suggested names are not ambiguous' '
+       git update-ref refs/heads/origin/not-local HEAD &&
+       test_must_fail git merge not-local 2>stderr &&
+       grep remotes/origin/not-local stderr
+'
+
 test_done