From: kristofferhaugsbakk@fastmail.com
To: git@vger.kernel.org
Cc: Kristoffer Haugsbakk <code@khaugsbakk.name>, peff@peff.net
Subject: [PATCH 1/2] format-patch: make format.noprefix a boolean
Date: Wed, 18 Feb 2026 21:26:17 +0100 [thread overview]
Message-ID: <format.noprefix_boolean.39d@msgid.xyz> (raw)
In-Reply-To: <CV_format.noprefix_boolean.39c@msgid.xyz>
From: Kristoffer Haugsbakk <code@khaugsbakk.name>
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 hinting about the
previous behavior before dying.
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
builtin/log.c | 13 ++++++++++++-
t/t4014-format-patch.sh | 16 ++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/builtin/log.c b/builtin/log.c
index 5c9a8ef3632..e56af7465ae 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1096,7 +1096,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);
+ fprintf(stderr,
+ _("hint: '%s' used to accept any value but "
+ "now only\n"
+ "hint: accepts boolean values, like '%s'\n"),
+ var, "diff.noprefix");
+ exit(status);
+ }
return 0;
}
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 21d6d0cd9ef..645ac402a19 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 but now only
+ hint: accepts boolean values, like ${SQ}diff.noprefix${SQ}
+ EOF
+ test_must_fail git -c format.noprefix=not-a-bool \
+ format-patch -1 --stdout 2>actual &&
+ test_cmp expect actual
+'
+
test_done
--
2.53.0.26.g2afa8602a26
next prev parent reply other threads:[~2026-02-18 20:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 20:26 [PATCH 0/2] format-patch: make boolean and mention in diff-options.adoc kristofferhaugsbakk
2026-02-18 20:26 ` kristofferhaugsbakk [this message]
2026-02-19 18:03 ` [PATCH 1/2] format-patch: make format.noprefix a boolean Junio C Hamano
2026-02-23 23:25 ` Kristoffer Haugsbakk
2026-02-20 12:28 ` Jeff King
2026-02-18 20:26 ` [PATCH 2/2] doc: diff-options.adoc: show format.noprefix for format-patch kristofferhaugsbakk
2026-02-19 18:10 ` Junio C Hamano
2026-02-23 23:30 ` [PATCH v2 0/2] format-patch: make boolean and mention in diff-options.adoc kristofferhaugsbakk
2026-02-23 23:30 ` [PATCH v2 1/2] format-patch: make format.noprefix a boolean kristofferhaugsbakk
2026-02-23 23:30 ` [PATCH v2 2/2] doc: diff-options.adoc: show format.noprefix for format-patch kristofferhaugsbakk
2026-02-27 9:57 ` Jean-Noël Avila
2026-02-27 16:51 ` Junio C Hamano
2026-02-28 12:20 ` kristofferhaugsbakk
2026-02-28 14:08 ` Jean-Noël AVILA
2026-03-01 19:21 ` [PATCH v2] doc: diff-options.adoc: make *.noprefix split translatable kristofferhaugsbakk
2026-03-02 16:53 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=format.noprefix_boolean.39d@msgid.xyz \
--to=kristofferhaugsbakk@fastmail.com \
--cc=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.