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

"git submodule" command DWIMs the command line and assumes a unspecified action word for 'status' action. This is a UI mistake that leads to a confusing behaviour. A mistyped command name is instead treated as a request for 'status' of the submodule with that name, e.g. $ git submodule show error: pathspec 'show' did not match any file(s) known to git. Did you forget to 'git add'? Stop DWIMming an unknown or mistyped subcommand name as pathspec given to unspelled "status" subcommand. "git submodule" without any argument is still interpreted as "git submodule status", but its value is questionable. Adjust t7400 to match, and stop advertising the default subcommand being 'status' which does not help much in practice, other than promoting laziness and confusion. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramkumar Ramachandra committed Sep 22, 2012 at 16:57 UTC af9c9f97137dfb3f20a17d76520803c0312fd3e4
3 files changed +11 -4
Documentation/git-submodule.txt
-1
@@ -112,7 +112,6 @@ status::
112 initialized, `+` if the currently checked out submodule commit
113 does not match the SHA-1 found in the index of the containing
114 repository and `U` if the submodule has merge conflicts.
115 - This command is the default command for 'git submodule'.
115 +
116 If `--recursive` is specified, this command will recurse into nested
117 submodules, and show their status as well.
git-submodule.sh
+9 -1
@@ -1056,7 +1056,15 @@ do
1056 done
1057
1058 # No command word defaults to "status"
1059 -test -n "$command" || command=status
1059 +if test -z "$command"
1060 +then
1061 + if test $# = 0
1062 + then
1063 + command=status
1064 + else
1065 + usage
1066 + fi
1067 +fi
1068
1069 # "-b branch" is accepted only by "add"
1070 if test -n "$branch" && test "$command" != add
t/t7400-submodule-basic.sh
+2 -2
@@ -438,8 +438,8 @@ test_expect_success 'moving to a commit without submodule does not leave empty d
438 git checkout second
439 '
440
441 -test_expect_success 'submodule <invalid-path> warns' '
442 - test_failure_with_unknown_submodule
441 +test_expect_success 'submodule <invalid-subcommand> fails' '
442 + test_must_fail git submodule no-such-subcommand
443 '
444
445 test_expect_success 'add submodules without specifying an explicit path' '