Skip to content

Commit 75bf5e6

Browse files
William Entrikengitster
authored andcommitted
submodule update: when using recursion, show full path
Previously when using update with recursion, only the path for the inner-most module was printed. Now the path is printed relative to the directory the command was started from. This now matches the behavior of submodule foreach. Signed-off-by: William Entriken <[email protected]> Acked-by: Jens Lehmann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e6363a4 commit 75bf5e6

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
@@ -588,7 +588,7 @@ cmd_update()
588588
die_if_unmatched "$mode"
589589
if test "$stage" = U
590590
then
591-
echo >&2 "Skipping unmerged submodule $sm_path"
591+
echo >&2 "Skipping unmerged submodule $prefix$sm_path"
592592
continue
593593
fi
594594
name=$(module_name "$sm_path") || exit
@@ -602,7 +602,7 @@ cmd_update()
602602

603603
if test "$update_module" = "none"
604604
then
605-
echo "Skipping submodule '$sm_path'"
605+
echo "Skipping submodule '$prefix$sm_path'"
606606
continue
607607
fi
608608

@@ -611,7 +611,7 @@ cmd_update()
611611
# Only mention uninitialized submodules when its
612612
# path have been specified
613613
test "$#" != "0" &&
614-
say "$(eval_gettext "Submodule path '\$sm_path' not initialized
614+
say "$(eval_gettext "Submodule path '\$prefix\$sm_path' not initialized
615615
Maybe you want to use 'update --init'?")"
616616
continue
617617
fi
@@ -624,7 +624,7 @@ Maybe you want to use 'update --init'?")"
624624
else
625625
subsha1=$(clear_local_git_env; cd "$sm_path" &&
626626
git rev-parse --verify HEAD) ||
627-
die "$(eval_gettext "Unable to find current revision in submodule path '\$sm_path'")"
627+
die "$(eval_gettext "Unable to find current revision in submodule path '\$prefix\$sm_path'")"
628628
fi
629629

630630
if test "$subsha1" != "$sha1" -o -n "$force"
@@ -643,7 +643,7 @@ Maybe you want to use 'update --init'?")"
643643
(clear_local_git_env; cd "$sm_path" &&
644644
( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
645645
test -z "$rev") || git-fetch)) ||
646-
die "$(eval_gettext "Unable to fetch in submodule path '\$sm_path'")"
646+
die "$(eval_gettext "Unable to fetch in submodule path '\$prefix\$sm_path'")"
647647
fi
648648

649649
# Is this something we just cloned?
@@ -657,20 +657,20 @@ Maybe you want to use 'update --init'?")"
657657
case "$update_module" in
658658
rebase)
659659
command="git rebase"
660-
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$sm_path'")"
661-
say_msg="$(eval_gettext "Submodule path '\$sm_path': rebased into '\$sha1'")"
660+
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$prefix\$sm_path'")"
661+
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': rebased into '\$sha1'")"
662662
must_die_on_failure=yes
663663
;;
664664
merge)
665665
command="git merge"
666-
die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$sm_path'")"
667-
say_msg="$(eval_gettext "Submodule path '\$sm_path': merged in '\$sha1'")"
666+
die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$prefix\$sm_path'")"
667+
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': merged in '\$sha1'")"
668668
must_die_on_failure=yes
669669
;;
670670
*)
671671
command="git checkout $subforce -q"
672-
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$sm_path'")"
673-
say_msg="$(eval_gettext "Submodule path '\$sm_path': checked out '\$sha1'")"
672+
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$prefix\$sm_path'")"
673+
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': checked out '\$sha1'")"
674674
;;
675675
esac
676676

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

689689
if test -n "$recursive"
690690
then
691-
(clear_local_git_env; cd "$sm_path" && eval cmd_update "$orig_flags")
691+
(
692+
prefix="$prefix$sm_path/"
693+
clear_local_git_env
694+
cd "$sm_path" &&
695+
eval cmd_update "$orig_flags"
696+
)
692697
res=$?
693698
if test $res -gt 0
694699
then
695-
die_msg="$(eval_gettext "Failed to recurse into submodule path '\$sm_path'")"
700+
die_msg="$(eval_gettext "Failed to recurse into submodule path '\$prefix\$sm_path'")"
696701
if test $res -eq 1
697702
then
698703
err="${err};$die_msg"

t/t7406-submodule-update.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,8 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
612612
rm -rf super_update_r2 &&
613613
git clone super_update_r super_update_r2 &&
614614
(cd super_update_r2 &&
615-
git submodule update --init --recursive &&
615+
git submodule update --init --recursive >actual &&
616+
test_i18ngrep "Submodule path .submodule/subsubmodule.: checked out" actual &&
616617
(cd submodule/subsubmodule &&
617618
git log > ../../expected
618619
) &&

0 commit comments

Comments
 (0)