Skip to content

Commit 3614128

Browse files
jlehmanngitster
authored andcommitted
submodule update: remove unnecessary orig_flags variable
cmd_update() in the submodule script tries to preserve the options given on the command line in the "orig_flags" variable to pass them on into the recursion when the '--recursive' option is given. But this isn't necessary because all the variables set by the options will be seen in the recursion too as that is achieved by executing "eval cmd_update". The same has already been done for cmd_status() in e15bec0, so let's clean up cmd_update() likewise. Also add a test to make sure that a submodule name given on the command line is not passed into the recursion (which was the goal of adding the orig_flags variable in 98dbe63). Signed-off-by: Jens Lehmann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0ecd94d commit 3614128

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

git-submodule.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@ cmd_deinit()
706706
cmd_update()
707707
{
708708
# parse $args after "submodule ... update".
709-
orig_flags=
710709
while test $# -ne 0
711710
do
712711
case "$1" in
@@ -731,7 +730,6 @@ cmd_update()
731730
--reference)
732731
case "$2" in '') usage ;; esac
733732
reference="--reference=$2"
734-
orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")"
735733
shift
736734
;;
737735
--reference=*)
@@ -765,7 +763,6 @@ cmd_update()
765763
break
766764
;;
767765
esac
768-
orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")"
769766
shift
770767
done
771768

@@ -909,7 +906,7 @@ Maybe you want to use 'update --init'?")"
909906
prefix="$prefix$sm_path/"
910907
clear_local_git_env
911908
cd "$sm_path" &&
912-
eval cmd_update "$orig_flags"
909+
eval cmd_update
913910
)
914911
res=$?
915912
if test $res -gt 0

t/t7406-submodule-update.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,17 @@ test_expect_success 'submodule update clone shallow submodule' '
747747
(cd submodule &&
748748
test 1 = $(git log --oneline | wc -l)
749749
)
750+
)
751+
'
752+
753+
test_expect_success 'submodule update --recursive drops module name before recursing' '
754+
(cd super2 &&
755+
(cd deeper/submodule/subsubmodule &&
756+
git checkout HEAD^
757+
) &&
758+
git submodule update --recursive deeper/submodule >actual &&
759+
test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked out" actual
750760
)
751761
'
762+
752763
test_done

0 commit comments

Comments
 (0)