Merge branch 'lt/rename-no-extra-copy-detection' into maint
[gitweb.git] / t / t7505-prepare-commit-msg-hook.sh
index 802aa624d0ff6a1add2e1c7e40a651336b450053..5b4b694f1801f5c2284346f882cb496df9e7d74e 100755 (executable)
@@ -18,6 +18,9 @@ cat > fake-editor <<'EOF'
 exit 0
 EOF
 chmod +x fake-editor
+
+## Not using test_set_editor here so we can easily ensure the editor variable
+## is only set for the editor tests
 FAKE_EDITOR="$(pwd)/fake-editor"
 export FAKE_EDITOR
 
@@ -29,7 +32,7 @@ echo "#!$SHELL_PATH" > "$HOOK"
 cat >> "$HOOK" <<'EOF'
 
 if test "$2" = commit; then
-  source=$(git-rev-parse "$3")
+  source=$(git rev-parse "$3")
 else
   source=${2-default}
 fi
@@ -58,7 +61,7 @@ test_expect_success 'with hook (-m editor)' '
 
        echo "more" >> file &&
        git add file &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit -e -m "more more" &&
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -m "more more" &&
        test "`git log -1 --pretty=format:%s`" = message
 
 '
@@ -85,7 +88,7 @@ test_expect_success 'with hook (-F editor)' '
 
        echo "more" >> file &&
        git add file &&
-       (echo more more | GIT_EDITOR="$FAKE_EDITOR" git commit -e -F -) &&
+       (echo more more | GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -F -) &&
        test "`git log -1 --pretty=format:%s`" = message
 
 '
@@ -104,7 +107,7 @@ test_expect_success 'with hook (editor)' '
 
        echo "more more" >> file &&
        git add file &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit &&
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit &&
        test "`git log -1 --pretty=format:%s`" = default
 
 '
@@ -114,7 +117,7 @@ test_expect_success 'with hook (--amend)' '
        head=`git rev-parse HEAD` &&
        echo "more" >> file &&
        git add file &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit --amend &&
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --amend &&
        test "`git log -1 --pretty=format:%s`" = "$head"
 
 '
@@ -124,11 +127,23 @@ test_expect_success 'with hook (-c)' '
        head=`git rev-parse HEAD` &&
        echo "more" >> file &&
        git add file &&
-       GIT_EDITOR="$FAKE_EDITOR" git commit -c $head &&
+       GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head &&
        test "`git log -1 --pretty=format:%s`" = "$head"
 
 '
 
+test_expect_success 'with hook (merge)' '
+
+       head=`git rev-parse HEAD` &&
+       git checkout -b other HEAD@{1} &&
+       echo "more" >> file &&
+       git add file &&
+       git commit -m other &&
+       git checkout - &&
+       git merge other &&
+       test "`git log -1 --pretty=format:%s`" = merge
+'
+
 cat > "$HOOK" <<'EOF'
 #!/bin/sh
 exit 1
@@ -139,7 +154,7 @@ test_expect_success 'with failing hook' '
        head=`git rev-parse HEAD` &&
        echo "more" >> file &&
        git add file &&
-       ! GIT_EDITOR="$FAKE_EDITOR" git commit -c $head
+       ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head
 
 '
 
@@ -148,7 +163,7 @@ test_expect_success 'with failing hook (--no-verify)' '
        head=`git rev-parse HEAD` &&
        echo "more" >> file &&
        git add file &&
-       ! GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify -c $head
+       ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify -c $head
 
 '