Re: [PATCH] format-patch: teach format.useAutoBase "whenAble" option
From: Junio C Hamano <hidden>
Date: 2020-09-26 22:38:48
Jacob Keller [off-list ref] writes:
From: Jacob Keller <redacted>
The format.useAutoBase configuration option exists to allow users to
enable '--base=auto' for format-patch by default.
This can sometimes lead to poor workflow, due to unexpected failures
when attempting to format an ancient patch:
$ git format-patch -1 <an old commit>
fatal: base commit shouldn't be in revision list
This can be very confusing, as it is not necessarily immediately obvious
that the user requested a --base (since this was in the configuration,
not on the command line).
We do want --base=auto to fail when it cannot provide a suitable base,
as it would be equally confusing if a formatted patch did not include
the base information when it was requested.
Teach format.useAutoBase a new mode, "whenAble". This mode will cause
format-patch to attempt to include a base commit when it can. However,
if no valid base commit can be found, then format-patch will continue
formatting the patch without a base commit. --base also learns the same
mode using the term "if-able".
Add tests to cover the new mode of operation for --base.Two minor points. * would users get confused choosing between if-able and whenAble to use for the configuration and the command line option? * what if there is a branch called "if-able"? The same problem already exists with a refname "auto", and this makes it worse. I do not know what the best approach to solve the latter, but the former would be easier to solve by just picking one and sticking to it. Thanks.