Signed-off-by: Stefan Beller <sbel...@google.com>
---
 git-submodule.sh | 164 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 84 insertions(+), 80 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index c40d60f..2c9f1f2 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -625,6 +625,89 @@ cmd_update_clone()
        cmd_update_recursive
 }
 
+cmd_update_fetch()
+{
+       subsha1=$(clear_local_git_env; cd "$sm_path" &&
+               git rev-parse --verify HEAD) ||
+       die "$(eval_gettext "Unable to find current revision in submodule path 
'\$displaypath'")"
+
+       if test -n "$remote"
+       then
+               if test -z "$nofetch"
+               then
+                       # Fetch remote before determining tracking $sha1
+                       (clear_local_git_env; cd "$sm_path" && git-fetch) ||
+                       die "$(eval_gettext "Unable to fetch in submodule path 
'\$sm_path'")"
+               fi
+               remote_name=$(clear_local_git_env; cd "$sm_path" && 
get_default_remote)
+               sha1=$(clear_local_git_env; cd "$sm_path" &&
+                       git rev-parse --verify "${remote_name}/${branch}") ||
+               die "$(eval_gettext "Unable to find current 
${remote_name}/${branch} revision in submodule path '\$sm_path'")"
+       fi
+
+       if test "$subsha1" != "$sha1" || test -n "$force"
+       then
+               subforce=$force
+               # If we don't already have a -f flag and the submodule has 
never been checked out
+               if test -z "$subsha1" && test -z "$force"
+               then
+                       subforce="-f"
+               fi
+
+               if test -z "$nofetch"
+               then
+                       # Run fetch only if $sha1 isn't present or it
+                       # is not reachable from a ref.
+                       (clear_local_git_env; cd "$sm_path" &&
+                               ( (rev=$(git rev-list -n 1 $sha1 --not --all 
2>/dev/null) &&
+                                test -z "$rev") || git-fetch)) ||
+                       die "$(eval_gettext "Unable to fetch in submodule path 
'\$displaypath'")"
+               fi
+
+               must_die_on_failure=
+               case "$update_module" in
+               checkout)
+                       command="git checkout $subforce -q"
+                       die_msg="$(eval_gettext "Unable to checkout '\$sha1' in 
submodule path '\$displaypath'")"
+                       say_msg="$(eval_gettext "Submodule path 
'\$displaypath': checked out '\$sha1'")"
+                       ;;
+               rebase)
+                       command="git rebase"
+                       die_msg="$(eval_gettext "Unable to rebase '\$sha1' in 
submodule path '\$displaypath'")"
+                       say_msg="$(eval_gettext "Submodule path 
'\$displaypath': rebased into '\$sha1'")"
+                       must_die_on_failure=yes
+                       ;;
+               merge)
+                       command="git merge"
+                       die_msg="$(eval_gettext "Unable to merge '\$sha1' in 
submodule path '\$displaypath'")"
+                       say_msg="$(eval_gettext "Submodule path 
'\$displaypath': merged in '\$sha1'")"
+                       must_die_on_failure=yes
+                       ;;
+               !*)
+                       command="${update_module#!}"
+                       die_msg="$(eval_gettext "Execution of '\$command 
\$sha1' failed in submodule  path '\$prefix\$sm_path'")"
+                       say_msg="$(eval_gettext "Submodule path 
'\$prefix\$sm_path': '\$command \$sha1'")"
+                       must_die_on_failure=yes
+                       ;;
+               *)
+                       die "$(eval_gettext "Invalid update mode 
'$update_module' for submodule '$name'")"
+               esac
+
+               if (clear_local_git_env; cd "$sm_path" && $command "$sha1")
+               then
+                       say "$say_msg"
+               elif test -n "$must_die_on_failure"
+               then
+                       die_with_status 2 "$die_msg"
+               else
+                       err="${err};$die_msg"
+                       return
+               fi
+       fi
+
+       cmd_update_recursive
+}
+
 #
 # Update each submodule path to correct revision, using clone and checkout as 
needed
 #
@@ -743,88 +826,9 @@ Maybe you want to use 'update --init'?")"
                if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
                then
                        cmd_update_clone
-                       continue
                else
-                       subsha1=$(clear_local_git_env; cd "$sm_path" &&
-                               git rev-parse --verify HEAD) ||
-                       die "$(eval_gettext "Unable to find current revision in 
submodule path '\$displaypath'")"
+                       cmd_update_fetch
                fi
-
-               if test -n "$remote"
-               then
-                       if test -z "$nofetch"
-                       then
-                               # Fetch remote before determining tracking $sha1
-                               (clear_local_git_env; cd "$sm_path" && 
git-fetch) ||
-                               die "$(eval_gettext "Unable to fetch in 
submodule path '\$sm_path'")"
-                       fi
-                       remote_name=$(clear_local_git_env; cd "$sm_path" && 
get_default_remote)
-                       sha1=$(clear_local_git_env; cd "$sm_path" &&
-                               git rev-parse --verify 
"${remote_name}/${branch}") ||
-                       die "$(eval_gettext "Unable to find current 
${remote_name}/${branch} revision in submodule path '\$sm_path'")"
-               fi
-
-               if test "$subsha1" != "$sha1" || test -n "$force"
-               then
-                       subforce=$force
-                       # If we don't already have a -f flag and the submodule 
has never been checked out
-                       if test -z "$subsha1" && test -z "$force"
-                       then
-                               subforce="-f"
-                       fi
-
-                       if test -z "$nofetch"
-                       then
-                               # Run fetch only if $sha1 isn't present or it
-                               # is not reachable from a ref.
-                               (clear_local_git_env; cd "$sm_path" &&
-                                       ( (rev=$(git rev-list -n 1 $sha1 --not 
--all 2>/dev/null) &&
-                                        test -z "$rev") || git-fetch)) ||
-                               die "$(eval_gettext "Unable to fetch in 
submodule path '\$displaypath'")"
-                       fi
-
-                       must_die_on_failure=
-                       case "$update_module" in
-                       checkout)
-                               command="git checkout $subforce -q"
-                               die_msg="$(eval_gettext "Unable to checkout 
'\$sha1' in submodule path '\$displaypath'")"
-                               say_msg="$(eval_gettext "Submodule path 
'\$displaypath': checked out '\$sha1'")"
-                               ;;
-                       rebase)
-                               command="git rebase"
-                               die_msg="$(eval_gettext "Unable to rebase 
'\$sha1' in submodule path '\$displaypath'")"
-                               say_msg="$(eval_gettext "Submodule path 
'\$displaypath': rebased into '\$sha1'")"
-                               must_die_on_failure=yes
-                               ;;
-                       merge)
-                               command="git merge"
-                               die_msg="$(eval_gettext "Unable to merge 
'\$sha1' in submodule path '\$displaypath'")"
-                               say_msg="$(eval_gettext "Submodule path 
'\$displaypath': merged in '\$sha1'")"
-                               must_die_on_failure=yes
-                               ;;
-                       !*)
-                               command="${update_module#!}"
-                               die_msg="$(eval_gettext "Execution of 
'\$command \$sha1' failed in submodule  path '\$prefix\$sm_path'")"
-                               say_msg="$(eval_gettext "Submodule path 
'\$prefix\$sm_path': '\$command \$sha1'")"
-                               must_die_on_failure=yes
-                               ;;
-                       *)
-                               die "$(eval_gettext "Invalid update mode 
'$update_module' for submodule '$name'")"
-                       esac
-
-                       if (clear_local_git_env; cd "$sm_path" && $command 
"$sha1")
-                       then
-                               say "$say_msg"
-                       elif test -n "$must_die_on_failure"
-                       then
-                               die_with_status 2 "$die_msg"
-                       else
-                               err="${err};$die_msg"
-                               continue
-                       fi
-               fi
-
-               cmd_update_recursive
        done
 
        if test -n "$err"
-- 
2.6.0.rc0.131.gf624c3d

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to