@matheusbsbs / matheus-bagliano / commits / 1fb5fdd25f
Fork 0

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>

Erik Faye-Lund committed Mar 21, 2010 at 15:40 UTC 1fb5fdd25f018480b48f6a74f06bad7e04866440
2 files changed +13 -1
builtin-rev-list.c
+4 -1
@@ -133,9 +133,12 @@ static void show_commit(struct commit *commit, void *data)
133 */
134 if (graph_show_remainder(revs->graph))
135 putchar('\n');
136 + if (revs->commit_format == CMIT_FMT_ONELINE)
137 + putchar('\n');
138 }
139 } else {
138 - if (buf.len)
140 + if (revs->commit_format != CMIT_FMT_USERFORMAT ||
141 + buf.len)
142 printf("%s%c", buf.buf, info->hdr_termination);
143 }
144 strbuf_release(&buf);
t/t6006-rev-list-format.sh
+9
@@ -209,4 +209,13 @@ test_expect_success '%gd shortens ref name' '
209 test_cmp expect.gd-short actual.gd-short
210 '
211
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 +
221 test_done