Thread (24 messages) flat view 24 messages, 6 authors, 2016-06-15
STALE3728d

Revision rfc of 4 in this series.

Revisions (4)
  1. rfc current
  2. v2 [diff vs current]
  3. v3 [diff vs current]
  4. v4 [diff vs current]

[PATCH 2/2] submodule: drop the top-level requirement

From: John Keeping <hidden>
Date: 2016-06-15 22:56:43
Subsystem: the rest · Maintainer: Linus Torvalds

Use the new rev-parse --filename-prefix option to process all paths
given to the submodule command, dropping the requirement that it be run
from the top-level of the repository.

Signed-off-by: John Keeping <redacted>
---
 git-submodule.sh | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/git-submodule.sh b/git-submodule.sh
index 79bfaac..10216aa 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -14,10 +14,13 @@ USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <re
    or: $dashless [--quiet] foreach [--recursive] <command>
    or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
 OPTIONS_SPEC=
+SUBDIRECTORY_OK=Yes
 . git-sh-setup
 . git-sh-i18n
 . git-parse-remote
 require_work_tree
+wt_prefix=$(git rev-parse --show-prefix)
+cd_to_toplevel
 
 command=
 branch=
@@ -112,6 +115,7 @@ resolve_relative_url ()
 #
 module_list()
 {
+	eval "set $(git rev-parse --sq --filename-prefix "$wt_prefix" -- "$@")"
 	(
 		git ls-files --error-unmatch --stage -- "$@" ||
 		echo "unmatched pathspec exists"
@@ -335,6 +339,8 @@ cmd_add()
 		usage
 	fi
 
+	sm_path="$wt_prefix$sm_path"
+
 	# assure repo is absolute or relative to parent
 	case "$repo" in
 	./*|../*)
@@ -942,6 +948,7 @@ cmd_summary() {
 	fi
 
 	cd_to_toplevel
+	eval "set $(git rev-parse --sq --filename-prefix "$wt_prefix" -- "$@")"
 	# Get modified modules cared by user
 	modules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- "$@" |
 		sane_egrep '^:([0-7]* )?160000' |
-- 
1.8.2.694.ga76e9c3.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help