Skip to content

Commit d536a71

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e67010 commit d536a71

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

t/helper/test-mergesort.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static int compare_strings(const void *a, const void *b)
2323
return strcmp(x->text, y->text);
2424
}
2525

26-
int cmd__mergesort(int argc, const char **argv)
26+
static int sort_stdin(void)
2727
{
2828
struct line *line, *p = NULL, *lines = NULL;
2929
struct strbuf sb = STRBUF_INIT;
@@ -49,3 +49,10 @@ int cmd__mergesort(int argc, const char **argv)
4949
}
5050
return 0;
5151
}
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+
}

0 commit comments

Comments
 (0)