git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: submodule: if $command was not matched, don't parse other args

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 22, 2012, 20:31 UTC
Message-ID
<7v8vc13ilc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CALkWK0npySdS7FDt=6VKdtoNS2gqQH5WaTQ4H6TEmXdP9fuF=g@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 16 quoted lines
> When we try to execute 'git submodule' with an invalid subcommand, we
> get an error like the following:
>
>     $ git submodule show
>     error: pathspec 'show' did not match any file(s) known to git.
>     Did you forget to 'git add'?
>
> The cause of the problem: since $command is not matched, it is set to
> "status", and "show" is treated as an argument to "status".  Change
> this so that usage information is printed when an invalid subcommand
> is tried.
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  This breaks test 41 in t7400-submodule-bash -- does the test cover a
>  real-world usecase?

You know how to ask "shortlog --since=18.months --no-merges" to find people to list on "Cc:" line to ask that question, no?

Show 18 quoted lines
> diff --git a/git-submodule.sh b/git-submodule.sh
> index a7e933e..dfec45d 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -1108,7 +1108,15 @@ do
>  done
>
>  # No command word defaults to "status"
> -test -n "$command" || command=status
> +if test -z "$command"
> +then
> +    if test $# = 0
> +    then
> +	command=status
> +    else
> +	usage
> +    fi
> +fi

I personally feel "no command means this default" is a mistake for "git submodule", even if there is no pathspec or other arguments, but I am not a heavy user of submodules, so others should discuss this.

Previous: Ramkumar RamachandraNext: Jens Lehmann
Message 2 of 8 in “submodule: if $command was not matched, don't parse other args”
  1. Ramkumar RamachandraSep 22, 2012
  2. Junio C HamanoSep 22, 2012
  3. Jens LehmannSep 23, 2012
  4. Marc BranchaudSep 24, 2012
  5. Junio C HamanoSep 24, 2012
  6. Ramkumar RamachandraSep 24, 2012
  7. Junio C HamanoSep 24, 2012
  8. Ramkumar RamachandraSep 24, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.