]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper run-update-procedure: remove --suboid
authorGlen Choo <chooglen@google.com>
Sat, 5 Mar 2022 00:13:52 +0000 (16:13 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 5 Mar 2022 00:39:11 +0000 (16:39 -0800)
Teach run-update-procedure to determine the oid of the submodule's HEAD
instead of doing it in git-submodule.sh.

Signed-off-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
git-submodule.sh

index 1b67a3887c8020174f1287f3cfaae748de0a1eca..77ca4270f4cdb49198e0a38077b29f3881c5bf0f 100644 (file)
@@ -2594,9 +2594,6 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix)
                OPT_CALLBACK_F(0, "oid", &update_data.oid, N_("sha1"),
                               N_("SHA1 expected by superproject"), PARSE_OPT_NONEG,
                               parse_opt_object_id),
-               OPT_CALLBACK_F(0, "suboid", &update_data.suboid, N_("subsha1"),
-                              N_("SHA1 of submodule's HEAD"), PARSE_OPT_NONEG,
-                              parse_opt_object_id),
                OPT_END()
        };
 
@@ -3032,6 +3029,12 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)
 /* NEEDSWORK: this is a temporary name until we delete update_submodule() */
 static int update_submodule2(struct update_data *update_data)
 {
+       if (update_data->just_cloned)
+               oidcpy(&update_data->suboid, null_oid());
+       else if (resolve_gitlink_ref(update_data->sm_path, "HEAD", &update_data->suboid))
+               die(_("Unable to find current revision in submodule path '%s'"),
+                       update_data->displaypath);
+
        if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force)
                return do_run_update_procedure(update_data);
 
index 87772ac89174fa7d2d47262f164c2dbc9f854ba7..32a09302abe30033aed6e6d4160472374b68967b 100755 (executable)
@@ -406,14 +406,9 @@ cmd_update()
 
                displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
 
-               if test $just_cloned -eq 1
+               if test $just_cloned -eq 0
                then
-                       subsha1=
-               else
                        just_cloned=
-                       subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
-                               git rev-parse --verify HEAD) ||
-                       die "fatal: $(eval_gettext "Unable to find current revision in submodule path '\$displaypath'")"
                fi
 
                if test -n "$remote"
@@ -441,7 +436,6 @@ cmd_update()
                          ${update:+--update "$update"} \
                          ${prefix:+--recursive-prefix "$prefix"} \
                          ${sha1:+--oid "$sha1"} \
-                         ${subsha1:+--suboid "$subsha1"} \
                          "--" \
                          "$sm_path")