X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=git-merge-one-file.sh;h=c3eca8b3321df8dbf632fb687003737d8989d6f6;hb=706fe6ae03e2c1452d59892944701c56237b903f;hp=d9ee4581504984e4337a70433f82c411bb5a9c02;hpb=cb93c19365760d939f05d9a3c2ef4499f0d5ce16;p=git.git diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index d9ee4581..c3eca8b3 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -25,7 +25,8 @@ case "${1:-.}${2:-.}${3:-.}" in echo "Removing $4" fi if test -f "$4"; then - rm -f -- "$4" + rm -f -- "$4" && + rmdir -p "$(expr "$4" : '\(.*\)/')" 2>/dev/null fi && exec git-update-index --remove -- "$4" ;; @@ -64,7 +65,13 @@ case "${1:-.}${2:-.}${3:-.}" in # This extracts OUR file in $orig, and uses git-apply to # 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 + 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 ;; *) echo "Auto-merging $4."