Thread (5 messages) flat view 5 messages, 2 authors, 2016-06-15

Re: [PATCH] submodule: handle trailing slash, warn about non-submodules

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:07

Possibly related (same subject, not in this thread)

Johannes Schindelin [off-list ref] writes:
Earlier, when you called

	git submodule path/to/submodule/

(which happens easily if you are a heavy user of tab-completion), Git
would silently ignore the given path, as "git ls-files path/to/submodule/"
does not return anything due to the trailing slash.
I see a sign of concentrating too much on the topic you were interested in
to blind yourself here in this patch.
quoted hunk
diff --git a/git-submodule.sh b/git-submodule.sh
index 2f47e06..b878909 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -59,7 +59,19 @@ resolve_relative_url ()
 #
 module_list()
 {
-	git ls-files --stage -- "$@" | grep '^160000 '
+	while test $# -gt 0
+	do
+		line=$(git ls-files --stage "${1%/}" | grep '^160000 ')
+		case "$line" in
+		'')
+			echo "Warning: ignoring non-submodule '$1'" >&2
+			;;
+		*)
+			echo "$line"
+			;;
+		esac
+		shift
+	done
Almost everybody seems to call module_list with the arguments it received
from the caller, but that "$@" could be none.  Worse, cmd_foreach always
calls module_list with no argument.  Earlier you got all submodules, now
you get none.

So you would need:

        case $# in
        0)
                git ls-files --stage -- | grep '^160000 '
                ;;
        *)
                your while loop
                ;;
        esac

or something, I think.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help