Skip to content

Commit 483c9b8

Browse files
committed
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
2 parents 038226e + 6262fe9 commit 483c9b8

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

t/t7513-interpret-trailers.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,25 @@ test_expect_success 'with config option on the command line' '
9393
Acked-by: Johan
9494
Reviewed-by: Peff
9595
EOF
96-
echo "Acked-by: Johan" |
96+
{ echo; echo "Acked-by: Johan"; } |
9797
git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \
9898
--trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual &&
9999
test_cmp expected actual
100100
'
101101

102+
test_expect_success 'with only a title in the message' '
103+
cat >expected <<-\EOF &&
104+
area: change
105+
106+
Reviewed-by: Peff
107+
Acked-by: Johan
108+
EOF
109+
echo "area: change" |
110+
git interpret-trailers --trailer "Reviewed-by: Peff" \
111+
--trailer "Acked-by: Johan" >actual &&
112+
test_cmp expected actual
113+
'
114+
102115
test_expect_success 'with config setup' '
103116
git config trailer.ack.key "Acked-by: " &&
104117
cat >expected <<-\EOF &&

trailer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,10 @@ static int find_trailer_start(struct strbuf **lines, int count)
740740
/*
741741
* Get the start of the trailers by looking starting from the end
742742
* for a line with only spaces before lines with one separator.
743+
* The first line must not be analyzed as the others as it
744+
* should be either the message title or a blank line.
743745
*/
744-
for (start = count - 1; start >= 0; start--) {
746+
for (start = count - 1; start >= 1; start--) {
745747
if (lines[start]->buf[0] == comment_line_char)
746748
continue;
747749
if (contains_only_spaces(lines[start]->buf)) {

0 commit comments

Comments
 (0)