summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2015-08-28 12:32:17 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-08-28 12:32:17 -0700
commit483c9b8602eb2f4261d135c4332c4c48fa7eb8f6 (patch)
treec5c7bacbc8e7c6c4df31ef1ae4edc03fe72015b8
parentMerge branch 'dt/untracked-subdir' (diff)
parenttrailer: retitle a test and correct an in-comment message (diff)
downloadtgif-483c9b8602eb2f4261d135c4332c4c48fa7eb8f6.tar.xz
Merge branch 'cc/trailers-corner-case-fix'
"interpret-trailers" helper mistook a single-liner log message that has a colon as the end of existing trailer. * cc/trailers-corner-case-fix: trailer: retitle a test and correct an in-comment message trailer: ignore first line of message
-rwxr-xr-xt/t7513-interpret-trailers.sh15
-rw-r--r--trailer.c4
2 files changed, 17 insertions, 2 deletions
diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh
index bd0ab46750..9577b4effb 100755
--- a/t/t7513-interpret-trailers.sh
+++ b/t/t7513-interpret-trailers.sh
@@ -93,12 +93,25 @@ test_expect_success 'with config option on the command line' '
Acked-by: Johan
Reviewed-by: Peff
EOF
- echo "Acked-by: Johan" |
+ { echo; echo "Acked-by: Johan"; } |
git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \
--trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual &&
test_cmp expected actual
'
+test_expect_success 'with only a title in the message' '
+ cat >expected <<-\EOF &&
+ area: change
+
+ Reviewed-by: Peff
+ Acked-by: Johan
+ EOF
+ echo "area: change" |
+ git interpret-trailers --trailer "Reviewed-by: Peff" \
+ --trailer "Acked-by: Johan" >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'with config setup' '
git config trailer.ack.key "Acked-by: " &&
cat >expected <<-\EOF &&
diff --git a/trailer.c b/trailer.c
index 4b14a567b4..b8088687d4 100644
--- a/trailer.c
+++ b/trailer.c
@@ -740,8 +740,10 @@ static int find_trailer_start(struct strbuf **lines, int count)
/*
* Get the start of the trailers by looking starting from the end
* for a line with only spaces before lines with one separator.
+ * The first line must not be analyzed as the others as it
+ * should be either the message title or a blank line.
*/
- for (start = count - 1; start >= 0; start--) {
+ for (start = count - 1; start >= 1; start--) {
if (lines[start]->buf[0] == comment_line_char)
continue;
if (contains_only_spaces(lines[start]->buf)) {