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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 1, 2021 at 11:10 UTC 2e6701017ed6bfb9481e9d5ba5abb29cf4120321
1 file changed +2 -4
t/helper/test-mergesort.c
+2 -4
@@ -28,9 +28,7 @@ int cmd__mergesort(int argc, const char **argv)
28 struct line *line, *p = NULL, *lines = NULL;
29 struct strbuf sb = STRBUF_INIT;
30
31 - for (;;) {
32 - if (strbuf_getwholeline(&sb, stdin, '\n'))
33 - break;
31 + while (!strbuf_getline(&sb, stdin)) {
32 line = xmalloc(sizeof(struct line));
33 line->text = strbuf_detach(&sb, NULL);
34 if (p) {
@@ -46,7 +44,7 @@ int cmd__mergesort(int argc, const char **argv)
44 lines = llist_mergesort(lines, get_next, set_next, compare_strings);
45
46 while (lines) {
49 - printf("%s", lines->text);
47 + puts(lines->text);
48 lines = lines->next;
49 }
50 return 0;