aboutsummaryrefslogtreecommitdiff
path: root/t/t4014-format-patch.sh
diff options
context:
space:
mode:
authorKristoffer Haugsbakk <code@khaugsbakk.name>2026-02-24 00:30:50 +0100
committerJunio C Hamano <gitster@pobox.com>2026-02-23 15:55:19 -0800
commit04657ac02928bbd41fb4352db1bb0ba57488bad6 (patch)
treeaa2ee09d448bc079505ff00bbd0126bdf6e178b6 /t/t4014-format-patch.sh
parent67ad42147a7acc2af6074753ebd03d904476118f (diff)
downloadgit-04657ac02928bbd41fb4352db1bb0ba57488bad6.tar.xz
format-patch: make format.noprefix a boolean
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4014-format-patch.sh')
-rwxr-xr-xt/t4014-format-patch.sh16
1 files changed, 16 insertions, 0 deletions
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