Re: [PATCH] mergetool: Provide an empty file when no base exists
- From
David Aguilar <davvid@gmail.com>
- Date
- Jan 20, 2012, 07:07 UTC
- Message-ID
- <CAJDDKr5Z8JHq7H8ZZVLJvYaR+m4HarYdv2FB7p5ByYbDBemBig@mail.gmail.com>
- In-Reply-To
- <7vhazqhn8u.fsf@alter.siamese.dyndns.org>
On Thu, Jan 19, 2012 at 11:00 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 44 quoted lines
> David Aguilar <davvid@gmail.com> writes:
>
>> Some mergetools cannot cope when $BASE is missing.
>> This can happen when two branches add the same file.
>> Provide an empty file to make these tools happy.
>>
>> Reported-by: Jason Wenger <jcwenger@gmail.com>
>> Signed-off-by: David Aguilar <davvid@gmail.com>
>> ---
>> git-mergetool.sh | 6 +++++-
>> t/t7610-mergetool.sh | 27 ++++++++++++++++++++++++++-
>> 2 files changed, 31 insertions(+), 2 deletions(-)
>>
>> diff --git a/git-mergetool.sh b/git-mergetool.sh
>> index 085e213..8521b81 100755
>> --- a/git-mergetool.sh
>> +++ b/git-mergetool.sh
>> @@ -224,7 +224,11 @@ merge_file () {
>> mv -- "$MERGED" "$BACKUP"
>> cp -- "$BACKUP" "$MERGED"
>>
>> - base_present && checkout_staged_file 1 "$MERGED" "$BASE"
>> + if base_present; then
>> + checkout_staged_file 1 "$MERGED" "$BASE"
>> + else
>> + touch "$BASE"
>> + fi
>
> Using "touch" for things like this is a disease.
>
> You not just want to make sure it exists, but also you want to make sure
> it is empty, so it would make your intention more explicit and clear if
> you wrote this as
>
> >"$BASE"
>
> instead.
>
> I also wonder if it may help mergetools if we come up with a fake base
> image using the common material between the two files, in a way similar to
> how git-merge-one-file.sh does it (look for "Added $4 in both, but
> differently"), but obviously it would belong to a separate patch.
>
> Thanks.Ah, thanks for the pointer. I'll resend shortly. A "fake base" would be very helpful.
-- David