Skip to content

Commit

Permalink
Merge branch 'jc/commit-s-subject-is-not-a-footer'
Browse files Browse the repository at this point in the history
* jc/commit-s-subject-is-not-a-footer:
  builtin-commit.c: fix logic to omit empty line before existing footers
  • Loading branch information
Junio C Hamano committed Nov 7, 2009
2 parents ef05557 + e513843 commit 6e31f3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
for (i = sb.len - 1; i > 0 && sb.buf[i - 1] != '\n'; i--)
; /* do nothing */
if (prefixcmp(sb.buf + i, sob.buf)) {
if (!ends_rfc2822_footer(&sb))
if (!i || !ends_rfc2822_footer(&sb))
strbuf_addch(&sb, '\n');
strbuf_addbuf(&sb, &sob);
}
Expand Down
9 changes: 9 additions & 0 deletions t/t7502-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,13 @@ test_expect_success 'Hand committing of a redundant merge removes dups' '
'

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

test_done

0 comments on commit 6e31f3d

Please sign in to comment.