Re: [PATCH] mergetool: Provide an empty file when no base exists
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 20, 2012, 07:37 UTC
- Message-ID
- <7vy5t2g6za.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CAJDDKr490XFqGe+y1pa7fnNhPMRE3ZR3=A+_XNUrCA1GZv+wkw@mail.gmail.com>
David Aguilar <davvid@gmail.com> writes:
Show 7 quoted lines
>>> local_present && checkout_staged_file 2 "$MERGED" "$LOCAL" >>> remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE" >> >> Sorry to be ping-pong-ing like this, but wouldn't we have a similar issue >> when LOCAL or REMOTE does not exist (e.g. "they modified, we removed")? > > Yes. I'll have a [PATCH v3] soon.
It almost makes me wonder if the obviously simplest change to make checkout_staged_file create an empty file when the asked-for stage does not exist, i.e.
checkout_stage ()
{
if test -n "$1"
then
... whatever checkout_staged_file() does ...
else
>"$4"
fi
}checkout_stage $base_mode 1 "$MERGED" "$BASE" checkout_stage $local_mode 2 "$MERGED" "$LOCAL" checkout_stage $remote_mode 3 "$MERGED" "$REMOTE"
Or even:
checkout_stage ()
{
tmpfile=$(...)
if test $? -eq 0 -a ...
then
mv -- "$(git rev-parse ...)"
else
>"$3"
fi
}checkout_stage 1 "$MERGED" "$BASE" checkout_stage 2 "$MERGED" "$LOCAL" checkout_stage 3 "$MERGED" "$REMOTE"
as the current checkout_staged_file() does not seem to check errors in any meaningful way.