From 04657ac02928bbd41fb4352db1bb0ba57488bad6 Mon Sep 17 00:00:00 2001 From: Kristoffer Haugsbakk Date: Tue, 24 Feb 2026 00:30:50 +0100 Subject: [PATCH 1/2] format-patch: make format.noprefix a boolean MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The config `format.noprefix` was added in 8d5213de (format-patch: add format.noprefix option, 2023-03-09) to support no-prefix on paths. That was immediately after making git-format-patch(1) not respect `diff.noprefix`.[1] The intent was to mirror `diff.noprefix`. But this config was unintentionally[2] implemented by enabling no-prefix if any kind of value is set. † 1: c169af8f (format-patch: do not respect diff.noprefix, 2023-03-09) † 2: https://lore.kernel.org/all/20260211073553.GA1867915@coredump.intra.peff.net/ Let’s indeed mirror `diff.noprefix` by treating it as a boolean. This is a breaking change. And as far as breaking changes go it is pretty benign: • The documentation claims that this config is equivalent to `diff.noprefix`; this is just a bug fix if the documentation is what defines the application interface • Only users with non-boolean values will run into problems when we try to parse it as a boolean. But what would (1) make them suspect they could do that in the first place, and (2) have motivated them to do it? • Users who have set this to `false` and expect that to mean *enable format.noprefix* (current behavior) will now have the opposite experience. Which is not a reasonable setup. Let’s only offer a breaking change fig leaf by advising about the previous behavior before dying. Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- builtin/log.c | 14 +++++++++++++- t/t4014-format-patch.sh | 16 ++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/builtin/log.c b/builtin/log.c index 5c9a8ef363..275122b807 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -40,6 +40,7 @@ #include "mailmap.h" #include "progress.h" #include "commit-slab.h" +#include "advice.h" #include "commit-reach.h" #include "range-diff.h" @@ -1096,7 +1097,18 @@ static int git_format_config(const char *var, const char *value, return 0; } if (!strcmp(var, "format.noprefix")) { - format_no_prefix = 1; + format_no_prefix = git_parse_maybe_bool(value); + if (format_no_prefix < 0) { + int status = die_message( + _("bad boolean config value '%s' for '%s'"), + value, var); + advise(_("'%s' used to accept any value and " + "treat that as 'true'.\n" + "Now it only accepts boolean values, " + "like what '%s' does.\n"), + var, "diff.noprefix"); + exit(status); + } return 0; } diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 21d6d0cd9e..c20091e36f 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -2541,10 +2541,26 @@ test_expect_success 'format-patch respects format.noprefix' ' grep "^--- blorp" actual ' +test_expect_success 'format.noprefix=false' ' + git -c format.noprefix=false format-patch -1 --stdout >actual && + grep "^--- a/blorp" actual +' + test_expect_success 'format-patch --default-prefix overrides format.noprefix' ' git -c format.noprefix \ format-patch -1 --default-prefix --stdout >actual && grep "^--- a/blorp" actual ' +test_expect_success 'errors on format.noprefix which is not boolean' ' + cat >expect <<-EOF && + fatal: bad boolean config value ${SQ}not-a-bool${SQ} for ${SQ}format.noprefix${SQ} + hint: ${SQ}format.noprefix${SQ} used to accept any value and treat that as ${SQ}true${SQ}. + hint: Now it only accepts boolean values, like what ${SQ}diff.noprefix${SQ} does. + EOF + test_must_fail git -c format.noprefix=not-a-bool \ + format-patch -1 --stdout 2>actual && + test_cmp expect actual +' + test_done From 5eee5d81e42369e7e3b86dbc6f45e96c65c0bb1d Mon Sep 17 00:00:00 2001 From: Kristoffer Haugsbakk Date: Tue, 24 Feb 2026 00:30:51 +0100 Subject: [PATCH 2/2] doc: diff-options.adoc: show format.noprefix for format-patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-format-patch(1) uses `format.noprefix` and ignores `diff.noprefix`. The configuration variable `format.prefix` was added as an “escape hatch”, and “it’s unlikely that anybody really wants format. noprefix=true in the first place.”[1] Based on that there doesn’t seem to be a need to widely advertise this configuration variable. But in any case: the documentation for this option should not claim that it overrides a config that is always ignored. † 1: 8d5213de (format-patch: add format.noprefix option, 2023-03-09) Signed-off-by: Kristoffer Haugsbakk Signed-off-by: Junio C Hamano --- Documentation/diff-options.adoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/diff-options.adoc b/Documentation/diff-options.adoc index 9cdad6f72a..8f632d5fe1 100644 --- a/Documentation/diff-options.adoc +++ b/Documentation/diff-options.adoc @@ -860,7 +860,9 @@ endif::git-format-patch[] `--default-prefix`:: Use the default source and destination prefixes ("a/" and "b/"). - This overrides configuration variables such as `diff.noprefix`, + This overrides configuration variables such as +ifndef::git-format-patch[`diff.noprefix`,] +ifdef::git-format-patch[`format.noprefix`,] `diff.srcPrefix`, `diff.dstPrefix`, and `diff.mnemonicPrefix` (see linkgit:git-config[1]).