mergetool: Provide an empty file when needed
Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE are missing. $BASE can be missing when two branches independently add the same filename. Provide an empty file to make these tools happy. When a delete/modify conflict occurs, $LOCAL and $REMOTE can also be missing. We have special case code to handle such case so this change may not affect that codepath, but try to be consistent and create an empty file for them anyway. Reported-by: Jason Wenger <jcwenger@gmail.com> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
5fbdb9c2e8
commit
ec245ba049
@@ -181,10 +181,14 @@ stage_submodule () {
|
||||
}
|
||||
|
||||
checkout_staged_file () {
|
||||
tmpfile=$(expr "$(git checkout-index --temp --stage="$1" "$2")" : '\([^ ]*\) ')
|
||||
tmpfile=$(expr \
|
||||
"$(git checkout-index --temp --stage="$1" "$2" 2>/dev/null)" \
|
||||
: '\([^ ]*\) ')
|
||||
|
||||
if test $? -eq 0 -a -n "$tmpfile" ; then
|
||||
mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3"
|
||||
else
|
||||
>"$3"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -224,9 +228,9 @@ merge_file () {
|
||||
mv -- "$MERGED" "$BACKUP"
|
||||
cp -- "$BACKUP" "$MERGED"
|
||||
|
||||
base_present && checkout_staged_file 1 "$MERGED" "$BASE"
|
||||
local_present && checkout_staged_file 2 "$MERGED" "$LOCAL"
|
||||
remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
|
||||
checkout_staged_file 1 "$MERGED" "$BASE"
|
||||
checkout_staged_file 2 "$MERGED" "$LOCAL"
|
||||
checkout_staged_file 3 "$MERGED" "$REMOTE"
|
||||
|
||||
if test -z "$local_mode" -o -z "$remote_mode"; then
|
||||
echo "Deleted merge conflict for '$MERGED':"
|
||||
|
||||
Reference in New Issue
Block a user