From: Junio C Hamano Date: Thu, 5 Dec 2013 21:00:20 +0000 (-0800) Subject: Merge branch 'jl/submodule-update-retire-orig-flags' X-Git-Tag: v1.9-rc0~91 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c83386d14ded4968c93098d9413425ab29eb38a0?ds=inline;hp=-c Merge branch 'jl/submodule-update-retire-orig-flags' Code clean-up. * jl/submodule-update-retire-orig-flags: submodule update: remove unnecessary orig_flags variable --- c83386d14ded4968c93098d9413425ab29eb38a0 diff --combined git-submodule.sh index ed02f03214,74cbc53b53..2677f2e8b3 --- a/git-submodule.sh +++ b/git-submodule.sh @@@ -156,7 -156,7 +156,7 @@@ module_list( git ls-files -z --error-unmatch --stage -- "$@" || echo "unmatched pathspec exists" ) | - perl -e ' + @@PERL@@ -e ' my %unmerged = (); my ($null_sha1) = ("0" x 40); my @out = (); @@@ -545,12 -545,7 +545,12 @@@ cmd_foreach( sm_path=$(relative_path "$sm_path") && # we make $path available to scripts ... path=$sm_path && - eval "$@" && + if test $# -eq 1 + then + eval "$1" + else + "$@" + fi && if test -n "$recursive" then cmd_foreach "--recursive" "$@" @@@ -617,21 -612,11 +617,21 @@@ cmd_init( fi # Copy "update" setting when it is not set yet - upd="$(git config -f .gitmodules submodule."$name".update)" - test -z "$upd" || - test -n "$(git config submodule."$name".update)" || - git config submodule."$name".update "$upd" || - die "$(eval_gettext "Failed to register update mode for submodule path '\$displaypath'")" + if upd="$(git config -f .gitmodules submodule."$name".update)" && + test -n "$upd" && + test -z "$(git config submodule."$name".update)" + then + case "$upd" in + rebase | merge | none) + ;; # known modes of updating + *) + echo >&2 "warning: unknown update mode '$upd' suggested for submodule '$name'" + upd=none + ;; + esac + git config submodule."$name".update "$upd" || + die "$(eval_gettext "Failed to register update mode for submodule path '\$displaypath'")" + fi done } @@@ -721,7 -706,6 +721,6 @@@ cmd_deinit( cmd_update() { # parse $args after "submodule ... update". - orig_flags= while test $# -ne 0 do case "$1" in @@@ -746,7 -730,6 +745,6 @@@ --reference) case "$2" in '') usage ;; esac reference="--reference=$2" - orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")" shift ;; --reference=*) @@@ -780,7 -763,6 +778,6 @@@ break ;; esac - orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")" shift done @@@ -924,7 -906,7 +921,7 @@@ Maybe you want to use 'update --init'?" prefix="$prefix$sm_path/" clear_local_git_env cd "$sm_path" && - eval cmd_update "$orig_flags" + eval cmd_update ) res=$? if test $res -gt 0 diff --combined t/t7406-submodule-update.sh index 0825a928df,2d9db8e8b7..0246e80b1a --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@@ -323,21 -323,6 +323,21 @@@ test_expect_success 'submodule update ) ' +test_expect_success 'submodule init does not copy command into .git/config' ' + (cd super && + H=$(git ls-files -s submodule | cut -d" " -f2) && + mkdir submodule1 && + git update-index --add --cacheinfo 160000 $H submodule1 && + git config -f .gitmodules submodule.submodule1.path submodule1 && + git config -f .gitmodules submodule.submodule1.url ../submodule && + git config -f .gitmodules submodule.submodule1.update !false && + git submodule init submodule1 && + echo "none" >expect && + git config submodule.submodule1.update >actual && + test_cmp expect actual + ) +' + test_expect_success 'submodule init picks up rebase' ' (cd super && git config -f .gitmodules submodule.rebasing.update rebase && @@@ -762,6 -747,17 +762,17 @@@ test_expect_success 'submodule update c (cd submodule && test 1 = $(git log --oneline | wc -l) ) + ) + ' + + test_expect_success 'submodule update --recursive drops module name before recursing' ' + (cd super2 && + (cd deeper/submodule/subsubmodule && + git checkout HEAD^ + ) && + git submodule update --recursive deeper/submodule >actual && + test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked out" actual ) ' + test_done