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 <github.com@phor.net> Acked-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

William Entriken committed Mar 2, 2013 at 14:44 UTC 75bf5e60e8c09075af1e4cd0d68a6d73fdf92c42
2 files changed +20 -14
git-submodule.sh
+18 -13
@@ -588,7 +588,7 @@ cmd_update()
588 die_if_unmatched "$mode"
589 if test "$stage" = U
590 then
591 - echo >&2 "Skipping unmerged submodule $sm_path"
591 + echo >&2 "Skipping unmerged submodule $prefix$sm_path"
592 continue
593 fi
594 name=$(module_name "$sm_path") || exit
@@ -602,7 +602,7 @@ cmd_update()
602
603 if test "$update_module" = "none"
604 then
605 - echo "Skipping submodule '$sm_path'"
605 + echo "Skipping submodule '$prefix$sm_path'"
606 continue
607 fi
608
@@ -611,7 +611,7 @@ cmd_update()
611 # Only mention uninitialized submodules when its
612 # path have been specified
613 test "$#" != "0" &&
614 - say "$(eval_gettext "Submodule path '\$sm_path' not initialized
614 + say "$(eval_gettext "Submodule path '\$prefix\$sm_path' not initialized
615 Maybe you want to use 'update --init'?")"
616 continue
617 fi
@@ -624,7 +624,7 @@ Maybe you want to use 'update --init'?")"
624 else
625 subsha1=$(clear_local_git_env; cd "$sm_path" &&
626 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'")"
628 fi
629
630 if test "$subsha1" != "$sha1" -o -n "$force"
@@ -643,7 +643,7 @@ Maybe you want to use 'update --init'?")"
643 (clear_local_git_env; cd "$sm_path" &&
644 ( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
645 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'")"
647 fi
648
649 # Is this something we just cloned?
@@ -657,20 +657,20 @@ Maybe you want to use 'update --init'?")"
657 case "$update_module" in
658 rebase)
659 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'")"
662 must_die_on_failure=yes
663 ;;
664 merge)
665 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'")"
668 must_die_on_failure=yes
669 ;;
670 *)
671 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'")"
674 ;;
675 esac
676
@@ -688,11 +688,16 @@ Maybe you want to use 'update --init'?")"
688
689 if test -n "$recursive"
690 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 + )
697 res=$?
698 if test $res -gt 0
699 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'")"
701 if test $res -eq 1
702 then
703 err="${err};$die_msg"
t/t7406-submodule-update.sh
+2 -1
@@ -612,7 +612,8 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
612 rm -rf super_update_r2 &&
613 git clone super_update_r super_update_r2 &&
614 (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 &&
617 (cd submodule/subsubmodule &&
618 git log > ../../expected
619 ) &&