git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git submodule output on invalid command
@ 2008-09-05 16:16 Pieter de Bie
  2008-09-05 18:52 ` Re* " Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Pieter de Bie @ 2008-09-05 16:16 UTC (permalink / raw)
  To: Git Mailinglist

If you give git submodule an invalid commands, it outputs nothing.
For example:

	Vienna:git pieter$ git submodule satsus
	Vienna:git pieter$

This is because the default command is 'status' and status accepts paths to
limit the output.

I tried to find a fix for this, but git-submodule also allows a syntax
like

	git submodule --cached status
and
	git submodule --cached

so you can't just look at the first argument to see if a command is valid.
Similarly, the default command is 'status', so something like

	Vienna:bonnenteller pieter$ git submodule vendor/
	ef38bc83b7ff4b290a6b1f4d82df03585fbb7529 vendor/plugins/will_paginate (2.3.2)

is also valid. Using that line of reasoning, something like 'git submodule satsus'
is valid and should return nothing, because there are no submodules in
the 'satsus' path. However, I still feel this should produce a warning.

I'm sure there is a nicer way to alert the user than my patch below, which
warns if the user did not supply any valid paths. Anyone else got a more
satisfying approach?

- Pieter

diff --git a/git-submodule.sh b/git-submodule.sh
index 1c39b59..3aae746 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -59,7 +59,12 @@ resolve_relative_url ()
 #
 module_list()
 {
-       git ls-files --stage -- "$@" | grep '^160000 '
+       git ls-files --stage -- "$@" | grep '^160000 ' ||
+       if test -z "$@"; then
+               die "This repository contains no submodules"
+       else
+               die "Could not find any submodules in paths $@"
+       fi
 }
 
 #

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

end of thread, other threads:[~2008-09-06  5:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-05 16:16 git submodule output on invalid command Pieter de Bie
2008-09-05 18:52 ` Re* " Junio C Hamano
2008-09-06  4:22   ` David Aguilar
2008-09-06  5:03     ` Junio C Hamano

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).