mirror of
https://github.com/git/git
synced 2024-10-06 00:29:28 +00:00
interpret-trailers: load default config
The interpret-trailers program does not do the usual loading of config via git_default_config(), and thus does not respect many of the usual options. In particular, we will not load core.commentChar, even though the underlying trailer code uses its value. This can be seen in the accompanying test, where setting core.commentChar to anything besides "#" results in a failure to treat the comments correctly. Reported-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
0d0ac3826a
commit
29c83fc23f
|
@ -10,6 +10,7 @@
|
||||||
#include "parse-options.h"
|
#include "parse-options.h"
|
||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
#include "trailer.h"
|
#include "trailer.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
static const char * const git_interpret_trailers_usage[] = {
|
static const char * const git_interpret_trailers_usage[] = {
|
||||||
N_("git interpret-trailers [--in-place] [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"),
|
N_("git interpret-trailers [--in-place] [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]"),
|
||||||
|
@ -112,6 +113,8 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
git_config(git_default_config, NULL);
|
||||||
|
|
||||||
argc = parse_options(argc, argv, prefix, options,
|
argc = parse_options(argc, argv, prefix, options,
|
||||||
git_interpret_trailers_usage, 0);
|
git_interpret_trailers_usage, 0);
|
||||||
|
|
||||||
|
|
|
@ -538,33 +538,50 @@ test_expect_success 'with 2 files arguments' '
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'with message that has comments' '
|
# Cover multiple comment characters with the same test input.
|
||||||
cat basic_message >message_with_comments &&
|
for char in "#" ";"
|
||||||
sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF &&
|
do
|
||||||
# comment
|
case "$char" in
|
||||||
|
"#")
|
||||||
|
# This is the default, so let's explicitly _not_
|
||||||
|
# set any config to make sure it behaves as we expect.
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
config="-c core.commentChar=$char"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# other comment
|
test_expect_success "with message that has comments ($char)" '
|
||||||
Cc: Z
|
cat basic_message >message_with_comments &&
|
||||||
# yet another comment
|
sed -e "s/ Z\$/ /" \
|
||||||
Reviewed-by: Johan
|
-e "s/#/$char/g" >>message_with_comments <<-EOF &&
|
||||||
Reviewed-by: Z
|
# comment
|
||||||
# last comment
|
|
||||||
|
|
||||||
EOF
|
# other comment
|
||||||
cat basic_patch >>message_with_comments &&
|
Cc: Z
|
||||||
cat basic_message >expected &&
|
# yet another comment
|
||||||
cat >>expected <<-\EOF &&
|
Reviewed-by: Johan
|
||||||
# comment
|
Reviewed-by: Z
|
||||||
|
# last comment
|
||||||
|
|
||||||
Reviewed-by: Johan
|
EOF
|
||||||
Cc: Peff
|
cat basic_patch >>message_with_comments &&
|
||||||
# last comment
|
cat basic_message >expected &&
|
||||||
|
sed -e "s/#/$char/g" >>expected <<-\EOF &&
|
||||||
|
# comment
|
||||||
|
|
||||||
EOF
|
Reviewed-by: Johan
|
||||||
cat basic_patch >>expected &&
|
Cc: Peff
|
||||||
git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual &&
|
# last comment
|
||||||
test_cmp expected actual
|
|
||||||
'
|
EOF
|
||||||
|
cat basic_patch >>expected &&
|
||||||
|
git $config interpret-trailers \
|
||||||
|
--trim-empty --trailer "Cc: Peff" \
|
||||||
|
message_with_comments >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
done
|
||||||
|
|
||||||
test_expect_success 'with message that has an old style conflict block' '
|
test_expect_success 'with message that has an old style conflict block' '
|
||||||
cat basic_message >message_with_comments &&
|
cat basic_message >message_with_comments &&
|
||||||
|
|
Loading…
Reference in a new issue