mirror of
https://github.com/git/git.git
synced 2026-03-04 06:27:36 +01:00
Merge branch 'kh/format-patch-noprefix-is-boolean' into jch
The configuration variable format.noprefix did not behave as a proper boolean variable, which has now been fixed and documented. * kh/format-patch-noprefix-is-boolean: doc: diff-options.adoc: make *.noprefix split translatable doc: diff-options.adoc: show format.noprefix for format-patch format-patch: make format.noprefix a boolean
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user