submodule--helper: remove ensure-core-worktree

Move the logic of "git submodule--helper ensure-core-worktree" into run-update-procedure, and since this makes the ensure-core-worktree command obsolete, remove it. As a result, the order of two operations in git-submodule.sh is reversed: 'set the value of core.worktree' now happens after the call to "git submodule--helper relative-path". This is safe - "relative-path" does not depend on the value of core.worktree. 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 97cb977c8243c3393a85d662456a1e161596f211
2 files changed +2 -12
builtin/submodule--helper.c
+2 -10
@@ -2783,17 +2783,11 @@ static int push_check(int argc, const char **argv, const char *prefix)
2783 return 0;
2784 }
2785
2786 -static int ensure_core_worktree(int argc, const char **argv, const char *prefix)
2786 +static void ensure_core_worktree(const char *path)
2787 {
2788 - const char *path;
2788 const char *cw;
2789 struct repository subrepo;
2790
2792 - if (argc != 2)
2793 - BUG("submodule--helper ensure-core-worktree <path>");
2794 -
2795 - path = argv[1];
2796 -
2791 if (repo_submodule_init(&subrepo, the_repository, path, null_oid()))
2792 die(_("could not get a repository handle for submodule '%s'"), path);
2793
@@ -2813,8 +2807,6 @@ static int ensure_core_worktree(int argc, const char **argv, const char *prefix)
2807 free(abs_path);
2808 strbuf_release(&sb);
2809 }
2816 -
2817 - return 0;
2810 }
2811
2812 static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
@@ -3041,6 +3033,7 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)
3033 /* NEEDSWORK: this is a temporary name until we delete update_submodule() */
3034 static int update_submodule2(struct update_data *update_data)
3035 {
3036 + ensure_core_worktree(update_data->sm_path);
3037 if (update_data->just_cloned)
3038 oidcpy(&update_data->suboid, null_oid());
3039 else if (resolve_gitlink_ref(update_data->sm_path, "HEAD", &update_data->suboid))
@@ -3459,7 +3452,6 @@ static struct cmd_struct commands[] = {
3452 {"add", module_add, SUPPORT_SUPER_PREFIX},
3453 {"update-clone", update_clone, 0},
3454 {"run-update-procedure", run_update_procedure, 0},
3462 - {"ensure-core-worktree", ensure_core_worktree, 0},
3455 {"relative-path", resolve_relative_path, 0},
3456 {"resolve-relative-url-test", resolve_relative_url_test, 0},
3457 {"foreach", module_foreach, SUPPORT_SUPER_PREFIX},
git-submodule.sh
-2
@@ -385,8 +385,6 @@ cmd_update()
385 do
386 die_if_unmatched "$quickabort" "$sha1"
387
388 - git submodule--helper ensure-core-worktree "$sm_path" || exit 1
389 -
388 displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
389
390 if test $just_cloned -eq 0