submodule--helper run-update-procedure: remove --suboid

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>

Glen Choo committed Mar 4, 2022 at 16:13 UTC e44196659634fdc42672888f5a91e94303052284
2 files changed +7 -10
builtin/submodule--helper.c
+6 -3
@@ -2594,9 +2594,6 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix)
2594 OPT_CALLBACK_F(0, "oid", &update_data.oid, N_("sha1"),
2595 N_("SHA1 expected by superproject"), PARSE_OPT_NONEG,
2596 parse_opt_object_id),
2597 - OPT_CALLBACK_F(0, "suboid", &update_data.suboid, N_("subsha1"),
2598 - N_("SHA1 of submodule's HEAD"), PARSE_OPT_NONEG,
2599 - parse_opt_object_id),
2597 OPT_END()
2598 };
2599
@@ -3032,6 +3029,12 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)
3029 /* NEEDSWORK: this is a temporary name until we delete update_submodule() */
3030 static int update_submodule2(struct update_data *update_data)
3031 {
3032 + if (update_data->just_cloned)
3033 + oidcpy(&update_data->suboid, null_oid());
3034 + else if (resolve_gitlink_ref(update_data->sm_path, "HEAD", &update_data->suboid))
3035 + die(_("Unable to find current revision in submodule path '%s'"),
3036 + update_data->displaypath);
3037 +
3038 if (!oideq(&update_data->oid, &update_data->suboid) || update_data->force)
3039 return do_run_update_procedure(update_data);
3040
git-submodule.sh
+1 -7
@@ -406,14 +406,9 @@ cmd_update()
406
407 displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
408
409 - if test $just_cloned -eq 1
409 + if test $just_cloned -eq 0
410 then
411 - subsha1=
412 - else
411 just_cloned=
414 - subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
415 - git rev-parse --verify HEAD) ||
416 - die "fatal: $(eval_gettext "Unable to find current revision in submodule path '\$displaypath'")"
412 fi
413
414 if test -n "$remote"
@@ -441,7 +436,6 @@ cmd_update()
436 ${update:+--update "$update"} \
437 ${prefix:+--recursive-prefix "$prefix"} \
438 ${sha1:+--oid "$sha1"} \
444 - ${subsha1:+--suboid "$subsha1"} \
439 "--" \
440 "$sm_path")
441