Thread (1 message) 1 message, 1 author, 2016-06-15
DORMANTno replies

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

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:46:06
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

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.

Git would also silently ignore paths that do not point to submodules at
all, without warning the user about the likely mistake.

Now, "git submodule" strips trailing slashes, and it warns about parameters
that are no submodules.

Signed-off-by: Johannes Schindelin <redacted>
---
 git-submodule.sh |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
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
 }
 
 #
-- 
1.6.1.2.630.g01a7e
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help