test-submodule: remove command line handling for check-name
The 'check-name' subcommand to 'test-tool submodule' is documented as being able to take a command line argument '<name>'. However, this does not work - and has never worked - because 'argc > 0' triggers the usage message in 'cmd__submodule_check_name()'. To simplify the helper and avoid future confusion around proper use of the subcommand, remove any references to command line arguments for 'check-name' in usage strings and handling in 'check_name()'. Helped-by: Jeff King <peff@peff.net> Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Victoria Dye committed
Jan 18, 2024 at 01:55 UTC
6af2c4ad45083df07b81ebb2c449f97f0bb69315
1 file changed
+9
-20
t/helper/test-submodule.c
+9
-20
@@ -8,7 +8,7 @@
8
#include "submodule.h"
9
10
#define TEST_TOOL_CHECK_NAME_USAGE \
11
- "test-tool submodule check-name <name>"
11
+ "test-tool submodule check-name"
12
static const char *submodule_check_name_usage[] = {
13
TEST_TOOL_CHECK_NAME_USAGE,
14
NULL
@@ -35,26 +35,15 @@ static const char *submodule_usage[] = {
35
NULL
36
};
37
38
-/*
39
- * Exit non-zero if any of the submodule names given on the command line is
40
- * invalid. If no names are given, filter stdin to print only valid names
41
- * (which is primarily intended for testing).
42
- */
43
-static int check_name(int argc, const char **argv)
38
+/* Filter stdin to print only valid names. */
39
+static int check_name(void)
40
{
45
- if (argc > 1) {
46
- while (*++argv) {
47
- if (check_submodule_name(*argv) < 0)
48
- return 1;
49
- }
50
- } else {
51
- struct strbuf buf = STRBUF_INIT;
52
- while (strbuf_getline(&buf, stdin) != EOF) {
53
- if (!check_submodule_name(buf.buf))
54
- printf("%s\n", buf.buf);
55
- }
56
- strbuf_release(&buf);
41
+ struct strbuf buf = STRBUF_INIT;
42
+ while (strbuf_getline(&buf, stdin) != EOF) {
43
+ if (!check_submodule_name(buf.buf))
44
+ printf("%s\n", buf.buf);
45
}
46
+ strbuf_release(&buf);
47
return 0;
48
}
49
@@ -68,7 +57,7 @@ static int cmd__submodule_check_name(int argc, const char **argv)
57
if (argc)
58
usage_with_options(submodule_check_name_usage, options);
59
71
- return check_name(argc, argv);
60
+ return check_name();
61
}
62
63
static int cmd__submodule_is_active(int argc, const char **argv)