run_command: report failure to execute the program, but optionally don't
[gitweb.git] / git-merge-one-file.sh
index ebbb5759652c58916e5066f9f4f3f842d0c44492..9c2c1b7202462370509a7bdb391982ae32564bd6 100755 (executable)
@@ -27,8 +27,9 @@ case "${1:-.}${2:-.}${3:-.}" in
                # read-tree checked that index matches HEAD already,
                # so we know we do not have this path tracked.
                # there may be an unrelated working tree file here,
-               # which we should just leave unmolested.
-               exit 0
+               # which we should just leave unmolested.  Make sure
+               # we do not have it in the index, though.
+               exec git update-index --remove -- "$4"
        fi
        if test -f "$4"; then
                rm -f -- "$4" &&
@@ -42,15 +43,17 @@ case "${1:-.}${2:-.}${3:-.}" in
 #
 ".$2.")
        # the other side did not add and we added so there is nothing
-       # to be done.
+       # to be done, except making the path merged.
+       exec git update-index --add --cacheinfo "$6" "$2" "$4"
        ;;
 "..$3")
        echo "Adding $4"
-       test -f "$4" || {
+       if test -f "$4"
+       then
                echo "ERROR: untracked $4 is overwritten by the merge."
                exit 1
-       }
-       git update-index --add --cacheinfo "$6$7" "$2$3" "$4" &&
+       fi
+       git update-index --add --cacheinfo "$7" "$3" "$4" &&
                exec git checkout-index -u -f -- "$4"
        ;;
 
@@ -78,6 +81,10 @@ case "${1:-.}${2:-.}${3:-.}" in
                echo "ERROR: $4: Not merging symbolic link changes."
                exit 1
                ;;
+       *,160000,*)
+               echo "ERROR: $4: Not merging conflicting submodule changes."
+               exit 1
+               ;;
        esac
 
        src2=`git-unpack-file $3`
@@ -106,6 +113,10 @@ case "${1:-.}${2:-.}${3:-.}" in
        src1=`git-unpack-file $2`
        git merge-file "$src1" "$orig" "$src2"
        ret=$?
+       msg=
+       if [ $ret -ne 0 ]; then
+               msg='content conflict'
+       fi
 
        # Create the working tree file, using "our tree" version from the
        # index, and then store the result of the merge.
@@ -113,7 +124,10 @@ case "${1:-.}${2:-.}${3:-.}" in
        rm -f -- "$orig" "$src1" "$src2"
 
        if [ "$6" != "$7" ]; then
-               echo "ERROR: Permissions conflict: $5->$6,$7."
+               if [ -n "$msg" ]; then
+                       msg="$msg, "
+               fi
+               msg="${msg}permissions conflict: $5->$6,$7"
                ret=1
        fi
        if [ "$1" = '' ]; then
@@ -121,7 +135,7 @@ case "${1:-.}${2:-.}${3:-.}" in
        fi
 
        if [ $ret -ne 0 ]; then
-               echo "ERROR: Merge conflict in $4"
+               echo "ERROR: $msg in $4"
                exit 1
        fi
        exec git update-index -- "$4"