split the recursion part out to its own function

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

diff --git a/git-submodule.sh b/git-submodule.sh
index 8964b1d..71385cb 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -582,6 +582,31 @@ cmd_deinit()
        done
 }
 
+
+cmd_update_recursive()
+{
+       if test -n "$recursive"
+       then
+               (
+                       prefix="$prefix$sm_path/"
+                       clear_local_git_env
+                       cd "$sm_path" &&
+                       eval cmd_update
+               )
+               res=$?
+               if test $res -gt 0
+               then
+                       die_msg="$(eval_gettext "Failed to recurse into 
submodule path '\$displaypath'")"
+                       if test $res -eq 1
+                       then
+                               err="${err};$die_msg"
+                       else
+                               die_with_status $res "$die_msg"
+                       fi
+               fi
+       fi
+}
+
 #
 # Update each submodule path to correct revision, using clone and checkout as 
needed
 #
@@ -790,27 +815,7 @@ Maybe you want to use 'update --init'?")"
                        fi
                fi
 
-               if test -n "$recursive"
-               then
-                       (
-                               prefix="$prefix$sm_path/"
-                               clear_local_git_env
-                               cd "$sm_path" &&
-                               eval cmd_update
-                       )
-                       res=$?
-                       if test $res -gt 0
-                       then
-                               die_msg="$(eval_gettext "Failed to recurse into 
submodule path '\$displaypath'")"
-                               if test $res -eq 1
-                               then
-                                       err="${err};$die_msg"
-                                       continue
-                               else
-                                       die_with_status $res "$die_msg"
-                               fi
-                       fi
-               fi
+               cmd_update_recursive
        done
 
        if test -n "$err"
-- 
2.5.0.275.ge015d2a

--
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