Imported Upstream version 2.12.5
[platform/upstream/git.git] / git-difftool--helper.sh
index e6558d1..7bfb673 100755 (executable)
@@ -40,15 +40,17 @@ launch_merge_tool () {
        # the user with the real $MERGED name before launching $merge_tool.
        if should_prompt
        then
-               printf "\nViewing: '$MERGED'\n"
+               printf "\nViewing (%s/%s): '%s'\n" "$GIT_DIFF_PATH_COUNTER" \
+                       "$GIT_DIFF_PATH_TOTAL" "$MERGED"
                if use_ext_cmd
                then
-                       printf "Launch '%s' [Y/n]: " \
+                       printf "Launch '%s' [Y/n]? " \
                                "$GIT_DIFFTOOL_EXTCMD"
                else
-                       printf "Launch '%s' [Y/n]: " "$merge_tool"
+                       printf "Launch '%s' [Y/n]? " "$merge_tool"
                fi
-               if read ans && test "$ans" = n
+               read ans || return
+               if test "$ans" = n
                then
                        return
                fi
@@ -73,9 +75,31 @@ then
        fi
 fi
 
-# Launch the merge tool on each path provided by 'git diff'
-while test $# -gt 6
-do
-       launch_merge_tool "$1" "$2" "$5"
-       shift 7
-done
+if test -n "$GIT_DIFFTOOL_DIRDIFF"
+then
+       LOCAL="$1"
+       REMOTE="$2"
+       run_merge_tool "$merge_tool" false
+else
+       # Launch the merge tool on each path provided by 'git diff'
+       while test $# -gt 6
+       do
+               launch_merge_tool "$1" "$2" "$5"
+               status=$?
+               if test $status -ge 126
+               then
+                       # Command not found (127), not executable (126) or
+                       # exited via a signal (>= 128).
+                       exit $status
+               fi
+
+               if test "$status" != 0 &&
+                       test "$GIT_DIFFTOOL_TRUST_EXIT_CODE" = true
+               then
+                       exit $status
+               fi
+               shift 7
+       done
+fi
+
+exit 0