]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-merge-one-file.sh
Merge branch 'js/maint-merge-one-file-osx-expr'
[thirdparty/git.git] / git-merge-one-file.sh
index b86402afa5d079df8d1cf6eebb15e5727cc8a5de..f612cb847aca981e16cb6006fa08d870497c6263 100755 (executable)
@@ -22,6 +22,11 @@ LONG_USAGE="Usage: git merge-one-file $USAGE
 
 Blob ids and modes should be empty for missing files."
 
+SUBDIRECTORY_OK=Yes
+. git-sh-setup
+cd_to_toplevel
+require_work_tree
+
 if ! test "$#" -eq 7
 then
        echo "$LONG_USAGE"
@@ -112,7 +117,7 @@ case "${1:-.}${2:-.}${3:-.}" in
 
                # If we do not have enough common material, it is not
                # worth trying two-file merge using common subsections.
-               expr "$sz0" \< "$sz1" \* 2 >/dev/null || : >$orig
+               expr $sz0 \< $sz1 \* 2 >/dev/null || : >$orig
                ;;
        *)
                echo "Auto-merging $4"
@@ -132,7 +137,7 @@ case "${1:-.}${2:-.}${3:-.}" in
 
        # Create the working tree file, using "our tree" version from the
        # index, and then store the result of the merge.
-       git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4"
+       git checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4" || exit 1
        rm -f -- "$orig" "$src1" "$src2"
 
        if [ "$6" != "$7" ]; then