aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/diff-options.adoc8
-rw-r--r--builtin/log.c14
-rwxr-xr-xt/t4014-format-patch.sh16
3 files changed, 37 insertions, 1 deletions
diff --git a/Documentation/diff-options.adoc b/Documentation/diff-options.adoc
index 9cdad6f72a..fcfcdf0286 100644
--- a/Documentation/diff-options.adoc
+++ b/Documentation/diff-options.adoc
@@ -859,10 +859,18 @@ endif::git-format-patch[]
Do not show any source or destination prefix.
`--default-prefix`::
+ifdef::git-format-patch[]
+ Use the default source and destination prefixes ("a/" and "b/").
+ This overrides configuration variables such as `format.noprefix`,
+ `diff.srcPrefix`, `diff.dstPrefix`, and `diff.mnemonicPrefix`
+ (see linkgit:git-config[1]).
+endif::git-format-patch[]
+ifndef::git-format-patch[]
Use the default source and destination prefixes ("a/" and "b/").
This overrides configuration variables such as `diff.noprefix`,
`diff.srcPrefix`, `diff.dstPrefix`, and `diff.mnemonicPrefix`
(see linkgit:git-config[1]).
+endif::git-format-patch[]
`--line-prefix=<prefix>`::
Prepend an additional _<prefix>_ to every line of output.
diff --git a/builtin/log.c b/builtin/log.c
index 7cb919bca9..89e8b8f011 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -39,6 +39,7 @@
#include "mailmap.h"
#include "progress.h"
#include "commit-slab.h"
+#include "advice.h"
#include "commit-reach.h"
#include "range-diff.h"
@@ -1095,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);
+ 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 2135b65cee..bcdb944017 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -2549,10 +2549,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