i18n: git-add "The following paths are ignored" message
[gitweb.git] / git-mergetool.sh
index 2e3e02b3b5b45af781fea529e9f3f68fce4a9bd0..2f8dc441c6d575323f2fad920ecdb7b20e1445e6 100755 (executable)
@@ -174,9 +174,11 @@ merge_file () {
        read ans
     fi
 
-    present=false
-    base_present &&
-    present=true
+    if base_present; then
+           present=true
+    else
+           present=false
+    fi
 
     if ! run_merge_tool "$merge_tool" "$present"; then
        echo "merge of $MERGED failed" 1>&2
@@ -254,33 +256,54 @@ prompt_after_failed_merge() {
     done
 }
 
-merge_tool=$(get_merge_tool "$merge_tool") || exit
-merge_tool_cmd="$(get_merge_tool_cmd "$merge_tool")"
-merge_tool_path="$(get_merge_tool_path "$merge_tool")" || exit
+if test -z "$merge_tool"; then
+    merge_tool=$(get_merge_tool "$merge_tool") || exit
+fi
 merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
 merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
-merge_tool_trust_exit_code="$(git config --bool mergetool."$merge_tool".trustExitCode || echo false)"
 
 last_status=0
 rollup_status=0
+rerere=false
+
+files_to_merge() {
+    if test "$rerere" = true
+    then
+       git rerere status
+    else
+       git ls-files -u | sed -e 's/^[^ ]*      //' | sort -u
+    fi
+}
+
 
 if test $# -eq 0 ; then
-    files=$(git ls-files -u | sed -e 's/^[^    ]*      //' | sort -u)
+    cd_to_toplevel
+
+    if test -e "$GIT_DIR/MERGE_RR"
+    then
+       rerere=true
+    fi
+
+    files=$(files_to_merge)
     if test -z "$files" ; then
        echo "No files need merging"
        exit 0
     fi
-    echo Merging the files: "$files"
-    git ls-files -u |
-    sed -e 's/^[^      ]*      //' |
-    sort -u |
+
+    # Save original stdin
+    exec 3<&0
+
+    printf "Merging:\n"
+    printf "$files\n"
+
+    files_to_merge |
     while IFS= read i
     do
        if test $last_status -ne 0; then
-           prompt_after_failed_merge < /dev/tty || exit 1
+           prompt_after_failed_merge <&3 || exit 1
        fi
        printf "\n"
-       merge_file "$i" < /dev/tty > /dev/tty
+       merge_file "$i" <&3
        last_status=$?
        if test $last_status -ne 0; then
            rollup_status=1