Subject: Re: [PATCH v2] branch: do not fail a no-op --edit-desc

From: Junio C Hamano <[email-masked]>
Date: Fri, 30 Sep 2022 11:13:40 -0700

Ævar Arnfjörð Bjarmason <[email-masked]> writes:

>> Ah, OK, so in short, _gently() is still unusable to use for that.  I
>> guess it means that the approach taken by v1 would be a better
>> solution, then.
>
> As you noted it's got a TOCTOU instead, so we might wipe away good
> config entirely.

I do not think that is the case.

What you have in mind is probably something entirely different.  If
you open two windows, start "edit description" in both, write a
description in one of them, then write a different description in
another, depending on the order you save the buffer and cause the
"git branch --edit-desc" that invoked the editor to use the edited
result, the description written in the editor that was later closed
will win, instead of telling you "you started from state X and you
want to update to state Y, but in the meantime somebody else made it
state Z, so I won't overwrite it with state Y".  But that has always
been with us, IIUC.

The only "funny" thing the change makes it do is leave the good
config as-is, if the user starts without an existing branch
description and exits with an empty edit buffer, instead of removing
the description written in the other window in the meantime.  That
is quite far from wiping away good config entirely.