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>
This commit is contained in:

committed by
Junio C Hamano

parent
13320ff610
commit
6af2c4ad45
@ -8,7 +8,7 @@
|
|||||||
#include "submodule.h"
|
#include "submodule.h"
|
||||||
|
|
||||||
#define TEST_TOOL_CHECK_NAME_USAGE \
|
#define TEST_TOOL_CHECK_NAME_USAGE \
|
||||||
"test-tool submodule check-name <name>"
|
"test-tool submodule check-name"
|
||||||
static const char *submodule_check_name_usage[] = {
|
static const char *submodule_check_name_usage[] = {
|
||||||
TEST_TOOL_CHECK_NAME_USAGE,
|
TEST_TOOL_CHECK_NAME_USAGE,
|
||||||
NULL
|
NULL
|
||||||
@ -35,26 +35,15 @@ static const char *submodule_usage[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/* Filter stdin to print only valid names. */
|
||||||
* Exit non-zero if any of the submodule names given on the command line is
|
static int check_name(void)
|
||||||
* invalid. If no names are given, filter stdin to print only valid names
|
|
||||||
* (which is primarily intended for testing).
|
|
||||||
*/
|
|
||||||
static int check_name(int argc, const char **argv)
|
|
||||||
{
|
{
|
||||||
if (argc > 1) {
|
|
||||||
while (*++argv) {
|
|
||||||
if (check_submodule_name(*argv) < 0)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
while (strbuf_getline(&buf, stdin) != EOF) {
|
while (strbuf_getline(&buf, stdin) != EOF) {
|
||||||
if (!check_submodule_name(buf.buf))
|
if (!check_submodule_name(buf.buf))
|
||||||
printf("%s\n", buf.buf);
|
printf("%s\n", buf.buf);
|
||||||
}
|
}
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +57,7 @@ static int cmd__submodule_check_name(int argc, const char **argv)
|
|||||||
if (argc)
|
if (argc)
|
||||||
usage_with_options(submodule_check_name_usage, options);
|
usage_with_options(submodule_check_name_usage, options);
|
||||||
|
|
||||||
return check_name(argc, argv);
|
return check_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cmd__submodule_is_active(int argc, const char **argv)
|
static int cmd__submodule_is_active(int argc, const char **argv)
|
||||||
|
Reference in New Issue
Block a user