Merge branch 'bl/trailers-and-incomplete-last-line-fix' into maint-2.46

The interpret-trailers command failed to recognise the end of the
message when the commit log ends in an incomplete line.

* bl/trailers-and-incomplete-last-line-fix:
  interpret-trailers: handle message without trailing newline
This commit is contained in:
Junio C Hamano
2024-09-23 10:32:59 -07:00
2 changed files with 41 additions and 0 deletions

View File

@ -132,6 +132,7 @@ static void read_input_file(struct strbuf *sb, const char *file)
if (strbuf_read(sb, fileno(stdin), 0) < 0)
die_errno(_("could not read from stdin"));
}
strbuf_complete_line(sb);
}
static void interpret_trailers(const struct process_trailer_options *opts,

View File

@ -175,6 +175,46 @@ test_expect_success 'with only a title in the message' '
test_cmp expected actual
'
test_expect_success 'with a bodiless message that lacks a trailing newline after the subject' '
cat >expected <<-\EOF &&
area: change
Reviewed-by: Peff
Acked-by: Johan
EOF
printf "area: change" |
git interpret-trailers --trailer "Reviewed-by: Peff" \
--trailer "Acked-by: Johan" >actual &&
test_cmp expected actual
'
test_expect_success 'with a bodied message that lacks a trailing newline after the body' '
cat >expected <<-\EOF &&
area: change
details about the change.
Reviewed-by: Peff
Acked-by: Johan
EOF
printf "area: change\n\ndetails about the change." |
git interpret-trailers --trailer "Reviewed-by: Peff" \
--trailer "Acked-by: Johan" >actual &&
test_cmp expected actual
'
test_expect_success 'with a message that lacks a trailing newline after the trailers' '
cat >expected <<-\EOF &&
area: change
Reviewed-by: Peff
Acked-by: Johan
EOF
printf "area: change\n\nReviewed-by: Peff" |
git interpret-trailers --trailer "Acked-by: Johan" >actual &&
test_cmp expected actual
'
test_expect_success 'with multiline title in the message' '
cat >expected <<-\EOF &&
place of