X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-merge-one-file.sh;h=f612cb847aca981e16cb6006fa08d870497c6263;hb=d24fbca7a5dcce2eb5e41266dd1be111b47a730c;hp=9c2c1b7202462370509a7bdb391982ae32564bd6;hpb=77f143bf3e218857ec8e5244d7e862e8e0c1a041;p=git.git diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index 9c2c1b720..f612cb847 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -16,6 +16,23 @@ # been handled already by git read-tree, but that one doesn't # do any merges that might change the tree layout. +USAGE=' ' +USAGE="$USAGE " +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" + exit 1 +fi + case "${1:-.}${2:-.}${3:-.}" in # # Deleted in both or deleted in one and unchanged in the other @@ -95,12 +112,12 @@ case "${1:-.}${2:-.}${3:-.}" in # remove lines that are unique to ours. orig=`git-unpack-file $2` sz0=`wc -c <"$orig"` - diff -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add + @@DIFF@@ -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add sz1=`wc -c <"$orig"` # 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" @@ -120,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