Re: [GSoC RFC PATCH v4 1/4] repo: declare the repo command
From: Lucas Seiki Oshiro <hidden>
Date: 2025-07-20 19:52:05
From: Lucas Seiki Oshiro <hidden>
Date: 2025-07-20 19:52:05
quoted
+ argc = parse_options(argc, argv, prefix, options, repo_usage, 0); + + if (fn) { + return fn(argc, argv, prefix, repo); + } else { + if (argc) { + error(_("unknown subcommand: `%s'"), argv[0]); + usage_with_options(repo_usage, options); + } + return 1;I think we need to print an error `if (!argc)`, as well. Otherwise the user wouldn't know why `git repo` without any argumentsdoesn't do anything.
Actually, it already does it! The subcommand parsing introduced in fa83cc834d (parse-options: add support for parsing subcommands, 2022-08-19) displays "error: need a subcommand" and the command usage when no subcommand is provided. Actually, this whole if-else can be removed. When an invalid command is provided, the execution is aborted in parse_options, so it's safe to assume that fn is a valid function. I'll change that.