From: Ramkumar Ramachandra Date: Sat, 22 Sep 2012 11:27:59 +0000 (+0530) Subject: submodule: if $command was not matched, don't parse other args X-Git-Tag: v1.8.0-rc0~11^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=af9c9f97137dfb3f20a17d76520803c0312fd3e4;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt index 2de7bf090..b4683bba1 100644 --- a/Documentation/git-submodule.txt +++ b/Documentation/git-submodule.txt @@ -112,7 +112,6 @@ status:: initialized, `+` if the currently checked out submodule commit does not match the SHA-1 found in the index of the containing repository and `U` if the submodule has merge conflicts. - This command is the default command for 'git submodule'. + If `--recursive` is specified, this command will recurse into nested submodules, and show their status as well. diff --git a/git-submodule.sh b/git-submodule.sh index e89b51603..152ad9214 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -1056,7 +1056,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 diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 0278f4839..442dc44e3 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -438,8 +438,8 @@ test_expect_success 'moving to a commit without submodule does not leave empty d git checkout second ' -test_expect_success 'submodule warns' ' - test_failure_with_unknown_submodule +test_expect_success 'submodule fails' ' + test_must_fail git submodule no-such-subcommand ' test_expect_success 'add submodules without specifying an explicit path' '