Skip to content

Commit 2e67010

Browse files
rscharfegitster
authored andcommitted
test-mergesort: use strbuf_getline()
Strip line ending characters to make sure empty lines are sorted like sort(1) does. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 94f6e3e commit 2e67010

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

t/helper/test-mergesort.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ int cmd__mergesort(int argc, const char **argv)
2828
struct line *line, *p = NULL, *lines = NULL;
2929
struct strbuf sb = STRBUF_INIT;
3030

31-
for (;;) {
32-
if (strbuf_getwholeline(&sb, stdin, '\n'))
33-
break;
31+
while (!strbuf_getline(&sb, stdin)) {
3432
line = xmalloc(sizeof(struct line));
3533
line->text = strbuf_detach(&sb, NULL);
3634
if (p) {
@@ -46,7 +44,7 @@ int cmd__mergesort(int argc, const char **argv)
4644
lines = llist_mergesort(lines, get_next, set_next, compare_strings);
4745

4846
while (lines) {
49-
printf("%s", lines->text);
47+
puts(lines->text);
5048
lines = lines->next;
5149
}
5250
return 0;

0 commit comments

Comments
 (0)