[PATCH 2/2] submodule: drop the top-level requirement
- From
John Keeping <john@keeping.me.uk>
- Date
- Apr 7, 2013, 19:55 UTC
- Message-ID
- <da121bcc33e63b7f33318ef920e85a77bb304d44.1365364193.git.john@keeping.me.uk>
- In-Reply-To
- <cover.1365364193.git.john@keeping.me.uk>
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 <john@keeping.me.uk> --- 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