Merge branch 'ef/maint-empty-commit-log'
authorJunio C Hamano <gitster@pobox.com>
Tue, 6 Apr 2010 21:50:46 +0000 (14:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Apr 2010 21:50:46 +0000 (14:50 -0700)
* ef/maint-empty-commit-log:
rev-list: fix --pretty=oneline with empty message

builtin/rev-list.c
t/t6006-rev-list-format.sh
index eb8e2c2056271345e42003ad5e51d775f8e07177..51ceb19d88918445c90eccc37f1fe5f90cedd385 100644 (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);
index b0047d3c6b593795561ce908ab8e10ff574d3dbc..d24ca5c077a0cd036645adb23795f1c75fba5d5a 100755 (executable)
@@ -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