git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/2] format-patch: make format.noprefix a boolean

From
Kkristofferhaugsbakk@fastmail.com <kristofferhaugsbakk@fastmail.com>
Date
Feb 23, 2026, 23:30 UTC
Message-ID
<V2_format.noprefix_boolean.422@msgid.xyz>
In-Reply-To
<V2_CV_format.noprefix_boolean.421@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 advising about the previous behavior before dying.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
Notes (series):
    v2:
    • Use `advise()` for the hint; you get the `hint:` prefix and color
    • Rework the hint, or the advise, to say that any value *used to be*
      treated as `true`. That better helps people who maybe set `nope` when
      they meant, “no, I don’t want any prefix” (for example)
 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 5c9a8ef3632..275122b807e 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 21d6d0cd9ef..c20091e36fe 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
-- 
2.53.0.26.g2afa8602a26
Previous: kristofferhaugsbakk@fastmail.comNext: kristofferhaugsbakk@fastmail.com
Message 9 of 16 in “format-patch: make boolean and mention in diff-options.adoc”
  1. 0/2 format-patch: make boolean and mention in diff-options.adockristofferhaugsbakk@fastmail.com, Feb 18, 2026
  2. 1/2 format-patch: make format.noprefix a booleankristofferhaugsbakk@fastmail.com, Feb 18, 2026
  3. Junio C HamanoFeb 19, 2026
  4. Kristoffer HaugsbakkFeb 23, 2026
  5. Jeff KingFeb 20, 2026
  6. 2/2 doc: diff-options.adoc: show format.noprefix for format-patchkristofferhaugsbakk@fastmail.com, Feb 18, 2026
  7. Junio C HamanoFeb 19, 2026
  8. 0/2 format-patch: make boolean and mention in diff-options.adockristofferhaugsbakk@fastmail.com, Feb 23, 2026
  9. 1/2 format-patch: make format.noprefix a booleankristofferhaugsbakk@fastmail.com, Feb 23, 2026
  10. 2/2 doc: diff-options.adoc: show format.noprefix for format-patchkristofferhaugsbakk@fastmail.com, Feb 23, 2026
  11. Jean-Noël AvilaFeb 27, 2026
  12. Junio C HamanoFeb 27, 2026
  13. kristofferhaugsbakk@fastmail.comFeb 28, 2026
  14. Jean-Noël AVILAFeb 28, 2026
  15. doc: diff-options.adoc: make *.noprefix split translatablekristofferhaugsbakk@fastmail.com, Mar 1, 2026
  16. Junio C HamanoMar 2, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.