[PATCH v2] trailer: load config to handle core.commentChar
- From
- Rafal Klys <rafalklys@wp.pl>
- Date
- Apr 28, 2016, 20:00 UTC
- Message-ID
- <1461873658-11394-1-git-send-email-rafalklys@wp.pl>
Fall throught git_default_config when reading config to update the comment_line_char from default '#' to possible different value set in core.commentChar.
Signed-off-by: Rafal Klys <rafalklys@wp.pl> ---
Added fallthru instead of reading config third time.
Added test, updated commit message.
I even tried to change that to only one pass, but looks like it would require a bit more coding, so maybe next time.
Thanks for feedback, I'm impressed that contributing to Git is so easy for newbies (never sent a patch via email before!) and that the response is so quick.
t/t7513-interpret-trailers.sh | 30 ++++++++++++++++++++++++++++++ trailer.c | 3 ++- 2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh index aee785c..e6f9d8e 100755 --- a/t/t7513-interpret-trailers.sh +++ b/t/t7513-interpret-trailers.sh @@ -267,6 +267,36 @@ test_expect_success 'with message that has comments' ' test_cmp expected actual ' +test_expect_success 'with message that has comments using non-default core.commentChar' ' + git config core.commentChar x && + test_when_finished "git config --unset core.commentChar" && + cat basic_message >message_with_comments && + sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF && + x comment + + x other comment + Cc: Z + x yet another comment + Reviewed-by: Johan + Reviewed-by: Z + x last comment + + EOF + cat basic_patch >>message_with_comments && + cat basic_message >expected && + cat >>expected <<-\EOF && + x comment + + Reviewed-by: Johan + Cc: Peff + x last comment + + EOF + cat basic_patch >>expected && + git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual && + test_cmp expected actual +' + test_expect_success 'with message that has an old style conflict block' ' cat basic_message >message_with_comments && sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF && diff --git a/trailer.c b/trailer.c index 8e48a5c..2ec0883 100644 --- a/trailer.c +++ b/trailer.c @@ -483,7 +483,8 @@ static int git_trailer_default_config(const char *conf_key, const char *value, v const char *trailer_item, *variable_name; if (!skip_prefix(conf_key, "trailer.", &trailer_item)) - return 0; + /* for core.commentChar */ + return git_default_config(conf_key, value, cb); variable_name = strrchr(trailer_item, '.'); if (!variable_name) {
-- 2.8.1.69.g6de72cc