Browse Source

Merge branch 'jk/trailers-use-config' into maint

"git interpret-trailers" always treated '#' as the comment
character, regardless of core.commentChar setting, which has been
corrected.

* jk/trailers-use-config:
  interpret-trailers: load default config
maint
Junio C Hamano 6 years ago
parent
commit
0100103d8e
  1. 3
      builtin/interpret-trailers.c
  2. 71
      t/t7513-interpret-trailers.sh

3
builtin/interpret-trailers.c

@ -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);



71
t/t7513-interpret-trailers.sh

@ -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

"#")
# other comment # This is the default, so let's explicitly _not_
Cc: Z # set any config to make sure it behaves as we expect.
# yet another comment ;;
Reviewed-by: Johan *)
Reviewed-by: Z config="-c core.commentChar=$char"
# last comment ;;

esac
EOF
cat basic_patch >>message_with_comments && test_expect_success "with message that has comments ($char)" '
cat basic_message >expected && cat basic_message >message_with_comments &&
cat >>expected <<-\EOF && sed -e "s/ Z\$/ /" \
# comment -e "s/#/$char/g" >>message_with_comments <<-EOF &&

# comment
Reviewed-by: Johan
Cc: Peff # other comment
# last comment Cc: Z

# yet another comment
EOF Reviewed-by: Johan
cat basic_patch >>expected && Reviewed-by: Z
git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual && # last comment
test_cmp expected actual
' EOF
cat basic_patch >>message_with_comments &&
cat basic_message >expected &&
sed -e "s/#/$char/g" >>expected <<-\EOF &&
# comment

Reviewed-by: Johan
Cc: Peff
# last comment

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…
Cancel
Save