Skip to content

Commit fd66dbf

Browse files
author
Junio C Hamano
committed
merge-one-file: use empty- or common-base condintionally in two-stage merge.
If two sides added the same path completely different thing, it is easier to see the merge pivoting on /dev/null. So check the size of the common section we have found, and empty it if it is too small. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent e433705 commit fd66dbf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

git-merge-one-file.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ case "${1:-.}${2:-.}${3:-.}" in
6464
# This extracts OUR file in $orig, and uses git-apply to
6565
# remove lines that are unique to ours.
6666
orig=`git-unpack-file $2`
67+
sz0=`wc -c <"$orig"`
6768
diff -u -La/$orig -Lb/$orig $orig $src2 | git-apply --no-add
69+
sz1=`wc -c <"$orig"`
70+
71+
# If we do not have enough common material, it is not
72+
# worth trying two-file merge using common subsections.
73+
expr "$sz0" \< "$sz1" \* 2 >/dev/null || : >$orig
6874
;;
6975
*)
7076
echo "Auto-merging $4."

0 commit comments

Comments
 (0)