Skip to content

Commit 1fb5fdd

Browse files
kusmagitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8fe5d87 commit 1fb5fdd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

builtin-rev-list.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,12 @@ static void show_commit(struct commit *commit, void *data)
133133
*/
134134
if (graph_show_remainder(revs->graph))
135135
putchar('\n');
136+
if (revs->commit_format == CMIT_FMT_ONELINE)
137+
putchar('\n');
136138
}
137139
} else {
138-
if (buf.len)
140+
if (revs->commit_format != CMIT_FMT_USERFORMAT ||
141+
buf.len)
139142
printf("%s%c", buf.buf, info->hdr_termination);
140143
}
141144
strbuf_release(&buf);

t/t6006-rev-list-format.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,13 @@ test_expect_success '%gd shortens ref name' '
209209
test_cmp expect.gd-short actual.gd-short
210210
'
211211

212+
test_expect_success 'oneline with empty message' '
213+
git commit -m "dummy" --allow-empty &&
214+
git commit -m "dummy" --allow-empty &&
215+
git filter-branch --msg-filter "sed -e s/dummy//" HEAD^^.. &&
216+
git rev-list --oneline HEAD > /tmp/test.txt &&
217+
test $(git rev-list --oneline HEAD | wc -l) -eq 5 &&
218+
test $(git rev-list --oneline --graph HEAD | wc -l) -eq 5
219+
'
220+
212221
test_done

0 commit comments

Comments
 (0)