add tests of commit --squash
[gitweb.git] / git-mergetool--lib.sh
index f7c571e73cdf471148b606242066536361ac7c3d..b5e1943b1d166b543998c80579c65e82de36516a 100644 (file)
@@ -1,3 +1,4 @@
+#!/bin/sh
 # git-mergetool--lib is a library for common merge tool functions
 diff_mode() {
        test "$TOOL_MODE" = diff
@@ -34,7 +35,7 @@ check_unchanged () {
                while true; do
                        echo "$MERGED seems unchanged."
                        printf "Was the merge successful? [y/n] "
-                       read answer < /dev/tty
+                       read answer
                        case "$answer" in
                        y*|Y*) status=0; break ;;
                        n*|N*) status=1; break ;;
@@ -338,15 +339,14 @@ guess_merge_tool () {
                fi
                tools="$tools gvimdiff diffuse ecmerge p4merge araxis"
        fi
-       if echo "${VISUAL:-$EDITOR}" | grep emacs > /dev/null 2>&1; then
-               # $EDITOR is emacs so add emerge as a candidate
-               tools="$tools emerge vimdiff"
-       elif echo "${VISUAL:-$EDITOR}" | grep vim > /dev/null 2>&1; then
-               # $EDITOR is vim so add vimdiff as a candidate
+       case "${VISUAL:-$EDITOR}" in
+       *vim*)
                tools="$tools vimdiff emerge"
-       else
+               ;;
+       *)
                tools="$tools emerge vimdiff"
-       fi
+               ;;
+       esac
        echo >&2 "merge tool candidates: $tools"
 
        # Loop over each candidate and stop when a valid merge tool is found.