rev-list: fix --pretty=oneline with empty message

55246aa (Dont use "<unknown>" for placeholders and suppress printing
of empty user formats) introduced a check to prevent empty
user-formats from being printed. This test didn't take empty commit
messages into account, and prevented the line-termination from being
output. This lead to multiple commits on a single line.

Correct it by guarding the check with a check for user-format. A
similar correction for the --graph code-path has been included.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Erik Faye-Lund 2010-03-21 15:40:16 +01:00 committed by Junio C Hamano
parent 8fe5d87622
commit 1fb5fdd25f
2 changed files with 13 additions and 1 deletions

View File

@ -133,9 +133,12 @@ static void show_commit(struct commit *commit, void *data)
*/
if (graph_show_remainder(revs->graph))
putchar('\n');
if (revs->commit_format == CMIT_FMT_ONELINE)
putchar('\n');
}
} else {
if (buf.len)
if (revs->commit_format != CMIT_FMT_USERFORMAT ||
buf.len)
printf("%s%c", buf.buf, info->hdr_termination);
}
strbuf_release(&buf);

View File

@ -209,4 +209,13 @@ test_expect_success '%gd shortens ref name' '
test_cmp expect.gd-short actual.gd-short
'
test_expect_success 'oneline with empty message' '
git commit -m "dummy" --allow-empty &&
git commit -m "dummy" --allow-empty &&
git filter-branch --msg-filter "sed -e s/dummy//" HEAD^^.. &&
git rev-list --oneline HEAD > /tmp/test.txt &&
test $(git rev-list --oneline HEAD | wc -l) -eq 5 &&
test $(git rev-list --oneline --graph HEAD | wc -l) -eq 5
'
test_done