Merge branch 'rr/maint-submodule-unknown-cmd' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 2 Oct 2012 20:42:32 +0000 (13:42 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Oct 2012 20:42:32 +0000 (13:42 -0700)
"git submodule frotz" was not diagnosed as "frotz" being an unknown
subcommand to "git submodule"; the user instead got a complaint that
"git submodule status" was run with an unknown path "frotz".

* rr/maint-submodule-unknown-cmd:
  submodule: if $command was not matched, don't parse other args

Documentation/git-submodule.txt
git-submodule.sh
t/t7400-submodule-basic.sh

index 2de7bf090094cd4a5c2d6697493040b445077bf7..b4683bba1bc0ea6561a2378c663cf431776a3f7a 100644 (file)
@@ -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.
index 3e2045e52daf43cc351af23af0fd770fb1a5044f..ab6b1107b6090494f192f361471ed5748ffa7dc1 100755 (executable)
@@ -1107,7 +1107,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
index 56a81cd7486716897cc4f08196d0815a62461ffd..53970374913eaa6f1b5921b14b5f25043974e3a4 100755 (executable)
@@ -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 <invalid-path> warns' '
-       test_failure_with_unknown_submodule
+test_expect_success 'submodule <invalid-subcommand> fails' '
+       test_must_fail git submodule no-such-subcommand
 '
 
 test_expect_success 'add submodules without specifying an explicit path' '