Skip to content

Commit f9bdf9b

Browse files
committed
Merge branch 'ef/maint-empty-commit-log'
* ef/maint-empty-commit-log: rev-list: fix --pretty=oneline with empty message
2 parents 15bf052 + 1fb5fdd commit f9bdf9b

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)