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>

René Scharfe committed Oct 1, 2021 at 11:11 UTC d536a711699dd369083b83dd98f3df1fdf2b08f0
1 file changed +8 -1
t/helper/test-mergesort.c
+8 -1
@@ -23,7 +23,7 @@ static int compare_strings(const void *a, const void *b)
23 return strcmp(x->text, y->text);
24 }
25
26 -int cmd__mergesort(int argc, const char **argv)
26 +static int sort_stdin(void)
27 {
28 struct line *line, *p = NULL, *lines = NULL;
29 struct strbuf sb = STRBUF_INIT;
@@ -49,3 +49,10 @@ int cmd__mergesort(int argc, const char **argv)
49 }
50 return 0;
51 }
52 +
53 +int cmd__mergesort(int argc, const char **argv)
54 +{
55 + if (argc == 2 && !strcmp(argv[1], "sort"))
56 + return sort_stdin();
57 + usage("test-tool mergesort sort");
58 +}