Skip to content

Commit 6e31f3d

Browse files
committed
Merge branch 'jc/commit-s-subject-is-not-a-footer'
* jc/commit-s-subject-is-not-a-footer: builtin-commit.c: fix logic to omit empty line before existing footers
2 parents ef05557 + e513843 commit 6e31f3d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

builtin-commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
530530
for (i = sb.len - 1; i > 0 && sb.buf[i - 1] != '\n'; i--)
531531
; /* do nothing */
532532
if (prefixcmp(sb.buf + i, sob.buf)) {
533-
if (!ends_rfc2822_footer(&sb))
533+
if (!i || !ends_rfc2822_footer(&sb))
534534
strbuf_addch(&sb, '\n');
535535
strbuf_addbuf(&sb, &sob);
536536
}

t/t7502-commit.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,13 @@ test_expect_success 'Hand committing of a redundant merge removes dups' '
258258
259259
'
260260

261+
test_expect_success 'A single-liner subject with a token plus colon is not a footer' '
262+
263+
git reset --hard &&
264+
git commit -s -m "hello: kitty" --allow-empty &&
265+
git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
266+
test $(wc -l <actual) = 3
267+
268+
'
269+
261270
test_done

0 commit comments

Comments
 (0)