diff options
author | René Scharfe <l.s.r@web.de> | 2021-10-01 11:10:09 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-10-01 12:43:08 -0700 |
commit | 2e6701017ed6bfb9481e9d5ba5abb29cf4120321 (patch) | |
tree | d22c35bcdb339f999e3ef5249033568deaae20d5 /t/helper | |
parent | Git 2.30.2 (diff) | |
download | tgif-2e6701017ed6bfb9481e9d5ba5abb29cf4120321.tar.xz |
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>
Diffstat (limited to 't/helper')
-rw-r--r-- | t/helper/test-mergesort.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c index c5cffaa4b7..621e2a5197 100644 --- a/t/helper/test-mergesort.c +++ b/t/helper/test-mergesort.c @@ -28,9 +28,7 @@ int cmd__mergesort(int argc, const char **argv) struct line *line, *p = NULL, *lines = NULL; struct strbuf sb = STRBUF_INIT; - for (;;) { - if (strbuf_getwholeline(&sb, stdin, '\n')) - break; + while (!strbuf_getline(&sb, stdin)) { line = xmalloc(sizeof(struct line)); line->text = strbuf_detach(&sb, NULL); if (p) { @@ -46,7 +44,7 @@ int cmd__mergesort(int argc, const char **argv) lines = llist_mergesort(lines, get_next, set_next, compare_strings); while (lines) { - printf("%s", lines->text); + puts(lines->text); lines = lines->next; } return 0; |