Skip to content

Commit 1c8d664

Browse files
committed
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
2 parents c7577ae + c02414a commit 1c8d664

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

builtin/interpret-trailers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ static void read_input_file(struct strbuf *sb, const char *file)
132132
if (strbuf_read(sb, fileno(stdin), 0) < 0)
133133
die_errno(_("could not read from stdin"));
134134
}
135+
strbuf_complete_line(sb);
135136
}
136137

137138
static void interpret_trailers(const struct process_trailer_options *opts,

t/t7513-interpret-trailers.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,46 @@ test_expect_success 'with only a title in the message' '
175175
test_cmp expected actual
176176
'
177177

178+
test_expect_success 'with a bodiless message that lacks a trailing newline after the subject' '
179+
cat >expected <<-\EOF &&
180+
area: change
181+
182+
Reviewed-by: Peff
183+
Acked-by: Johan
184+
EOF
185+
printf "area: change" |
186+
git interpret-trailers --trailer "Reviewed-by: Peff" \
187+
--trailer "Acked-by: Johan" >actual &&
188+
test_cmp expected actual
189+
'
190+
191+
test_expect_success 'with a bodied message that lacks a trailing newline after the body' '
192+
cat >expected <<-\EOF &&
193+
area: change
194+
195+
details about the change.
196+
197+
Reviewed-by: Peff
198+
Acked-by: Johan
199+
EOF
200+
printf "area: change\n\ndetails about the change." |
201+
git interpret-trailers --trailer "Reviewed-by: Peff" \
202+
--trailer "Acked-by: Johan" >actual &&
203+
test_cmp expected actual
204+
'
205+
206+
test_expect_success 'with a message that lacks a trailing newline after the trailers' '
207+
cat >expected <<-\EOF &&
208+
area: change
209+
210+
Reviewed-by: Peff
211+
Acked-by: Johan
212+
EOF
213+
printf "area: change\n\nReviewed-by: Peff" |
214+
git interpret-trailers --trailer "Acked-by: Johan" >actual &&
215+
test_cmp expected actual
216+
'
217+
178218
test_expect_success 'with multiline title in the message' '
179219
cat >expected <<-\EOF &&
180220
place of

0 commit comments

Comments
 (0)