Merge branch 'jk/HEAD-symref-in-xfer-namespaces'
[gitweb.git] / t / t7600-merge.sh
index 625a24a980c89a5fdda22c20860aa4675d7562c0..612ebe7d8289d10fe35a72945b5991dca169c1c2 100755 (executable)
@@ -233,20 +233,65 @@ test_expect_success 'merge --squash c3 with c7' '
        cat result.9z >file &&
        git commit --no-edit -a &&
 
-       {
-               cat <<-EOF
-               Squashed commit of the following:
+       cat >expect <<-EOF &&
+       Squashed commit of the following:
 
-               $(git show -s c7)
+       $(git show -s c7)
 
-               # Conflicts:
-               #       file
-               EOF
-       } >expect &&
-       git cat-file commit HEAD | sed -e '1,/^$/d' >actual &&
+       # Conflicts:
+       #       file
+       EOF
+       git cat-file commit HEAD >raw &&
+       sed -e '1,/^$/d' raw >actual &&
        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' '
@@ -680,10 +725,10 @@ cat >editor <<\EOF
 (
        echo "Merge work done on the side branch c1"
        echo
-       cat <"$1"
+       cat "$1"
 ) >"$1.tmp" && mv "$1.tmp" "$1"
 # strip comments and blank lines from end of message
-sed -e '/^#/d' < "$1" | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' > expected
+sed -e '/^#/d' "$1" | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' >expected
 EOF
 chmod 755 editor
 
@@ -768,14 +813,14 @@ test_expect_success 'set up mod-256 conflict scenario' '
        git commit -m base &&
 
        # one side changes the first line of each to "master"
-       sed s/-1/-master/ <file >tmp &&
+       sed s/-1/-master/ file >tmp &&
        mv tmp file &&
        git commit -am master &&
 
        # and the other to "side"; merging the two will
        # yield 256 separate conflicts
        git checkout -b side HEAD^ &&
-       sed s/-1/-side/ <file >tmp &&
+       sed s/-1/-side/ file >tmp &&
        mv tmp file &&
        git commit -am side
 '
@@ -814,7 +859,7 @@ EOF
 test_expect_success EXECKEEPSPID 'killed merge can be completed with --continue' '
        git reset --hard c0 &&
        ! "$SHELL_PATH" -c '\''
-         echo kill -TERM $$ >> .git/FAKE_EDITOR
+         echo kill -TERM $$ >>.git/FAKE_EDITOR
          GIT_EDITOR=.git/FAKE_EDITOR
          export GIT_EDITOR
          exec git merge --no-ff --edit c1'\'' &&
@@ -848,4 +893,24 @@ test_expect_success 'merge --quit' '
        )
 '
 
+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