提交 483c9b86 编写于 作者: J Junio C Hamano

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
...@@ -93,12 +93,25 @@ test_expect_success 'with config option on the command line' ' ...@@ -93,12 +93,25 @@ test_expect_success 'with config option on the command line' '
Acked-by: Johan Acked-by: Johan
Reviewed-by: Peff Reviewed-by: Peff
EOF EOF
echo "Acked-by: Johan" | { echo; echo "Acked-by: Johan"; } |
git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \ git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \
--trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual && --trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual &&
test_cmp expected 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' ' test_expect_success 'with config setup' '
git config trailer.ack.key "Acked-by: " && git config trailer.ack.key "Acked-by: " &&
cat >expected <<-\EOF && cat >expected <<-\EOF &&
......
...@@ -740,8 +740,10 @@ static int find_trailer_start(struct strbuf **lines, int count) ...@@ -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 * Get the start of the trailers by looking starting from the end
* for a line with only spaces before lines with one separator. * 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) if (lines[start]->buf[0] == comment_line_char)
continue; continue;
if (contains_only_spaces(lines[start]->buf)) { if (contains_only_spaces(lines[start]->buf)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册