Skip to content

Commit

Permalink
submodule update: when using recursion, show full path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
William Entriken authored and gitster committed Mar 4, 2013
1 parent e6363a4 commit 75bf5e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
31 changes: 18 additions & 13 deletions git-submodule.sh
Expand Up @@ -588,7 +588,7 @@ cmd_update()
die_if_unmatched "$mode" die_if_unmatched "$mode"
if test "$stage" = U if test "$stage" = U
then then
echo >&2 "Skipping unmerged submodule $sm_path" echo >&2 "Skipping unmerged submodule $prefix$sm_path"
continue continue
fi fi
name=$(module_name "$sm_path") || exit name=$(module_name "$sm_path") || exit
Expand All @@ -602,7 +602,7 @@ cmd_update()


if test "$update_module" = "none" if test "$update_module" = "none"
then then
echo "Skipping submodule '$sm_path'" echo "Skipping submodule '$prefix$sm_path'"
continue continue
fi fi


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


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


# Is this something we just cloned? # Is this something we just cloned?
Expand All @@ -657,20 +657,20 @@ Maybe you want to use 'update --init'?")"
case "$update_module" in case "$update_module" in
rebase) rebase)
command="git rebase" command="git rebase"
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$sm_path'")" die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$prefix\$sm_path'")"
say_msg="$(eval_gettext "Submodule path '\$sm_path': rebased into '\$sha1'")" say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': rebased into '\$sha1'")"
must_die_on_failure=yes must_die_on_failure=yes
;; ;;
merge) merge)
command="git merge" command="git merge"
die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$sm_path'")" die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$prefix\$sm_path'")"
say_msg="$(eval_gettext "Submodule path '\$sm_path': merged in '\$sha1'")" say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': merged in '\$sha1'")"
must_die_on_failure=yes must_die_on_failure=yes
;; ;;
*) *)
command="git checkout $subforce -q" command="git checkout $subforce -q"
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$sm_path'")" die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$prefix\$sm_path'")"
say_msg="$(eval_gettext "Submodule path '\$sm_path': checked out '\$sha1'")" say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': checked out '\$sha1'")"
;; ;;
esac esac


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


if test -n "$recursive" if test -n "$recursive"
then then
(clear_local_git_env; cd "$sm_path" && eval cmd_update "$orig_flags") (
prefix="$prefix$sm_path/"
clear_local_git_env
cd "$sm_path" &&
eval cmd_update "$orig_flags"
)
res=$? res=$?
if test $res -gt 0 if test $res -gt 0
then then
die_msg="$(eval_gettext "Failed to recurse into submodule path '\$sm_path'")" die_msg="$(eval_gettext "Failed to recurse into submodule path '\$prefix\$sm_path'")"
if test $res -eq 1 if test $res -eq 1
then then
err="${err};$die_msg" err="${err};$die_msg"
Expand Down
3 changes: 2 additions & 1 deletion t/t7406-submodule-update.sh
Expand Up @@ -612,7 +612,8 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
rm -rf super_update_r2 && rm -rf super_update_r2 &&
git clone super_update_r super_update_r2 && git clone super_update_r super_update_r2 &&
(cd super_update_r2 && (cd super_update_r2 &&
git submodule update --init --recursive && git submodule update --init --recursive >actual &&
test_i18ngrep "Submodule path .submodule/subsubmodule.: checked out" actual &&
(cd submodule/subsubmodule && (cd submodule/subsubmodule &&
git log > ../../expected git log > ../../expected
) && ) &&
Expand Down

0 comments on commit 75bf5e6

Please sign in to comment.