summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorLibravatar René Scharfe <l.s.r@web.de>2021-10-01 11:11:19 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-10-01 12:43:08 -0700
commitd536a711699dd369083b83dd98f3df1fdf2b08f0 (patch)
tree2f1565fc638ba42dab7153a7b9e76e8506a5b403 /t/helper
parenttest-mergesort: use strbuf_getline() (diff)
downloadtgif-d536a711699dd369083b83dd98f3df1fdf2b08f0.tar.xz
test-mergesort: add sort subcommand
Give the code for sorting a text file its own sub-command. This allows extending the helper, which we'll do in the following patches. 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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
index 621e2a5197..05be0d067a 100644
--- a/t/helper/test-mergesort.c
+++ b/t/helper/test-mergesort.c
@@ -23,7 +23,7 @@ static int compare_strings(const void *a, const void *b)
return strcmp(x->text, y->text);
}
-int cmd__mergesort(int argc, const char **argv)
+static int sort_stdin(void)
{
struct line *line, *p = NULL, *lines = NULL;
struct strbuf sb = STRBUF_INIT;
@@ -49,3 +49,10 @@ int cmd__mergesort(int argc, const char **argv)
}
return 0;
}
+
+int cmd__mergesort(int argc, const char **argv)
+{
+ if (argc == 2 && !strcmp(argv[1], "sort"))
+ return sort_stdin();
+ usage("test-tool mergesort sort");
+}