subtree: performance improvement for finding unexpected parent commits
[gitweb.git] / git-submodule.sh
index f7fd80345cd991df4b17c6598d7dd7bd462424c7..1b568e29b9a09af9fdecf19ddb75ffd2bdc6e094 100755 (executable)
@@ -534,31 +534,19 @@ cmd_update()
                "$@" || echo "#unmatched" $?
        } | {
        err=
-       while read -r mode sha1 stage just_cloned sm_path
+       while read -r quickabort sha1 just_cloned sm_path
        do
-               die_if_unmatched "$mode" "$sha1"
+               die_if_unmatched "$quickabort" "$sha1"
 
-               name=$(git submodule--helper name "$sm_path") || exit
-               if ! test -z "$update"
-               then
-                       update_module=$update
-               else
-                       update_module=$(git config submodule."$name".update)
-                       if test -z "$update_module"
-                       then
-                               update_module="checkout"
-                       fi
-               fi
+               git submodule--helper ensure-core-worktree "$sm_path"
+
+               update_module=$(git submodule--helper update-module-mode $just_cloned "$sm_path" $update)
 
                displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
 
                if test $just_cloned -eq 1
                then
                        subsha1=
-                       case "$update_module" in
-                       merge | rebase | none)
-                               update_module=checkout ;;
-                       esac
                else
                        subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
                                git rev-parse --verify HEAD) ||
@@ -580,11 +568,6 @@ cmd_update()
                        die "$(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")"
                fi
 
-               if ! $(git config -f "$(git rev-parse --git-common-dir)/modules/$name/config" core.worktree) 2>/dev/null
-               then
-                       git submodule--helper connect-gitdir-workingtree "$name" "$sm_path"
-               fi
-
                if test "$subsha1" != "$sha1" || test -n "$force"
                then
                        subforce=$force
@@ -635,7 +618,7 @@ cmd_update()
                                must_die_on_failure=yes
                                ;;
                        *)
-                               die "$(eval_gettext "Invalid update mode '$update_module' for submodule '$name'")"
+                               die "$(eval_gettext "Invalid update mode '$update_module' for submodule path '$path'")"
                        esac
 
                        if (sanitize_submodule_env; cd "$sm_path" && $command "$sha1")