Re: [GSoC RFC PATCH v4 1/4] repo: declare the repo command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> + 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.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux