Skip to content

Commit af9c9f9

Browse files
artagnongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bafc478 commit af9c9f9

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Documentation/git-submodule.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ status::
112112
initialized, `+` if the currently checked out submodule commit
113113
does not match the SHA-1 found in the index of the containing
114114
repository and `U` if the submodule has merge conflicts.
115-
This command is the default command for 'git submodule'.
116115
+
117116
If `--recursive` is specified, this command will recurse into nested
118117
submodules, and show their status as well.

git-submodule.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,15 @@ do
10561056
done
10571057

10581058
# 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
10601068

10611069
# "-b branch" is accepted only by "add"
10621070
if test -n "$branch" && test "$command" != add

t/t7400-submodule-basic.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ test_expect_success 'moving to a commit without submodule does not leave empty d
438438
git checkout second
439439
'
440440

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
443443
'
444444

445445
test_expect_success 'add submodules without specifying an explicit path' '

0 commit comments

Comments
 (0)