git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* submodule: if $command was not matched, don't parse other args
@ 2012-09-22 11:27 Ramkumar Ramachandra
  2012-09-22 20:31 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Ramkumar Ramachandra @ 2012-09-22 11:27 UTC (permalink / raw)
  To: Git List

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?

 git-submodule.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

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

 # "-b branch" is accepted only by "add"
 if test -n "$branch" && test "$command" != add
-- 
1.7.12.GIT

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-09-24 18:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-22 11:27 submodule: if $command was not matched, don't parse other args Ramkumar Ramachandra
2012-09-22 20:31 ` Junio C Hamano
2012-09-23 17:36   ` Jens Lehmann
2012-09-24 15:07     ` Marc Branchaud
2012-09-24 16:17       ` Junio C Hamano
2012-09-24 18:31         ` Ramkumar Ramachandra
2012-09-24 18:45           ` Junio C Hamano
2012-09-24 18:49             ` Ramkumar Ramachandra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).