Skip to content

Commit 50734ea

Browse files
committed
Merge branch 'we/submodule-update-prefix-output' into maint
"git submodule update", when recursed into sub-submodules, did not acccumulate the prefix paths. * we/submodule-update-prefix-output: submodule update: when using recursion, show full path
2 parents ece12fd + 75bf5e6 commit 50734ea

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

git-submodule.sh

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ cmd_update()
622622
die_if_unmatched "$mode"
623623
if test "$stage" = U
624624
then
625-
echo >&2 "Skipping unmerged submodule $sm_path"
625+
echo >&2 "Skipping unmerged submodule $prefix$sm_path"
626626
continue
627627
fi
628628
name=$(module_name "$sm_path") || exit
@@ -637,7 +637,7 @@ cmd_update()
637637

638638
if test "$update_module" = "none"
639639
then
640-
echo "Skipping submodule '$sm_path'"
640+
echo "Skipping submodule '$prefix$sm_path'"
641641
continue
642642
fi
643643

@@ -646,7 +646,7 @@ cmd_update()
646646
# Only mention uninitialized submodules when its
647647
# path have been specified
648648
test "$#" != "0" &&
649-
say "$(eval_gettext "Submodule path '\$sm_path' not initialized
649+
say "$(eval_gettext "Submodule path '\$prefix\$sm_path' not initialized
650650
Maybe you want to use 'update --init'?")"
651651
continue
652652
fi
@@ -659,7 +659,7 @@ Maybe you want to use 'update --init'?")"
659659
else
660660
subsha1=$(clear_local_git_env; cd "$sm_path" &&
661661
git rev-parse --verify HEAD) ||
662-
die "$(eval_gettext "Unable to find current revision in submodule path '\$sm_path'")"
662+
die "$(eval_gettext "Unable to find current revision in submodule path '\$prefix\$sm_path'")"
663663
fi
664664

665665
if test -n "$remote"
@@ -692,7 +692,7 @@ Maybe you want to use 'update --init'?")"
692692
(clear_local_git_env; cd "$sm_path" &&
693693
( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
694694
test -z "$rev") || git-fetch)) ||
695-
die "$(eval_gettext "Unable to fetch in submodule path '\$sm_path'")"
695+
die "$(eval_gettext "Unable to fetch in submodule path '\$prefix\$sm_path'")"
696696
fi
697697

698698
# Is this something we just cloned?
@@ -706,20 +706,20 @@ Maybe you want to use 'update --init'?")"
706706
case "$update_module" in
707707
rebase)
708708
command="git rebase"
709-
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$sm_path'")"
710-
say_msg="$(eval_gettext "Submodule path '\$sm_path': rebased into '\$sha1'")"
709+
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$prefix\$sm_path'")"
710+
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': rebased into '\$sha1'")"
711711
must_die_on_failure=yes
712712
;;
713713
merge)
714714
command="git merge"
715-
die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$sm_path'")"
716-
say_msg="$(eval_gettext "Submodule path '\$sm_path': merged in '\$sha1'")"
715+
die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$prefix\$sm_path'")"
716+
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': merged in '\$sha1'")"
717717
must_die_on_failure=yes
718718
;;
719719
*)
720720
command="git checkout $subforce -q"
721-
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$sm_path'")"
722-
say_msg="$(eval_gettext "Submodule path '\$sm_path': checked out '\$sha1'")"
721+
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$prefix\$sm_path'")"
722+
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': checked out '\$sha1'")"
723723
;;
724724
esac
725725

@@ -737,11 +737,16 @@ Maybe you want to use 'update --init'?")"
737737

738738
if test -n "$recursive"
739739
then
740-
(clear_local_git_env; cd "$sm_path" && eval cmd_update "$orig_flags")
740+
(
741+
prefix="$prefix$sm_path/"
742+
clear_local_git_env
743+
cd "$sm_path" &&
744+
eval cmd_update "$orig_flags"
745+
)
741746
res=$?
742747
if test $res -gt 0
743748
then
744-
die_msg="$(eval_gettext "Failed to recurse into submodule path '\$sm_path'")"
749+
die_msg="$(eval_gettext "Failed to recurse into submodule path '\$prefix\$sm_path'")"
745750
if test $res -eq 1
746751
then
747752
err="${err};$die_msg"

t/t7406-submodule-update.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
643643
rm -rf super_update_r2 &&
644644
git clone super_update_r super_update_r2 &&
645645
(cd super_update_r2 &&
646-
git submodule update --init --recursive &&
646+
git submodule update --init --recursive >actual &&
647+
test_i18ngrep "Submodule path .submodule/subsubmodule.: checked out" actual &&
647648
(cd submodule/subsubmodule &&
648649
git log > ../../expected
649650
) &&

0 commit comments

Comments
 (0)