Re: [GSoC RFC PATCH v4 1/4] repo: declare the repo command
- From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
- Date
- Jul 20, 2025, 19:51 UTC
- Message-ID
- <34671B47-21FF-464E-A811-32759D077A96@gmail.com>
- In-Reply-To
- <aHZChXPTbk_X6xDK@pks.im>
Show 14 quoted lines
>> + 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.