git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rev-list: fix --pretty=oneline with empty message
@ 2010-03-21 14:40 Erik Faye-Lund
  0 siblings, 0 replies; only message in thread
From: Erik Faye-Lund @ 2010-03-21 14:40 UTC (permalink / raw)
  To: git; +Cc: gitster

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>
---

Adjusted as suggested by Junio.

 builtin/rev-list.c         |    5 ++++-
 t/t6006-rev-list-format.sh |    9 +++++++++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 5679170..1db4b4c 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -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);
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index b0047d3..d24ca5c 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -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
-- 
1.7.0.2.456.g1a43b.dirty

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-03-21 14:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-21 14:40 [PATCH] rev-list: fix --pretty=oneline with empty message Erik Faye-Lund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).