Skip to content

Commit f7d24bb

Browse files
author
Junio C Hamano
committed
merge with /dev/null as base, instead of punting O==empty case
Instead of leaving the path unmerged in a case where each side adds different version of the same path, attempt to merge it with empty base and leave "our" version in the index file, just like we do for the case in conflicting merge. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 6fd72e3 commit f7d24bb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

git-merge-one-file.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ case "${1:-.}${2:-.}${3:-.}" in
4040
;;
4141

4242
#
43-
# Added in both (check for same permissions).
43+
# Added in both, identically (check for same permissions).
4444
#
4545
".$3$2")
4646
if [ "$6" != "$7" ]; then
@@ -56,9 +56,18 @@ case "${1:-.}${2:-.}${3:-.}" in
5656
#
5757
# Modified in both, but differently.
5858
#
59-
"$1$2$3")
60-
echo "Auto-merging $4."
61-
orig=`git-unpack-file $1`
59+
"$1$2$3" | ".$2$3")
60+
case "$1" in
61+
'')
62+
echo "Added $4 in both, but differently."
63+
orig=`git-unpack-file $2`
64+
: >$orig
65+
;;
66+
*)
67+
echo "Auto-merging $4."
68+
orig=`git-unpack-file $1`
69+
;;
70+
esac
6271
src2=`git-unpack-file $3`
6372

6473
# We reset the index to the first branch, making
@@ -73,6 +82,9 @@ case "${1:-.}${2:-.}${3:-.}" in
7382
echo "ERROR: Permissions conflict: $5->$6,$7."
7483
ret=1
7584
fi
85+
if [ "$1" = '' ]; then
86+
ret=1
87+
fi
7688

7789
if [ $ret -ne 0 ]; then
7890
echo "ERROR: Merge conflict in $4."

0 commit comments

Comments
 (0)