]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: remove ensure-core-worktree
authorGlen Choo <chooglen@google.com>
Sat, 5 Mar 2022 00:13:59 +0000 (16:13 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 5 Mar 2022 00:39:12 +0000 (16:39 -0800)
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>
builtin/submodule--helper.c
git-submodule.sh

index 17dabf3d1278af245a87833ad5f0188e45d0dbc5..296ab80bf27c30217be348bbcb3591d80efd6e47 100644 (file)
@@ -2783,17 +2783,11 @@ static int push_check(int argc, const char **argv, const char *prefix)
        return 0;
 }
 
-static int ensure_core_worktree(int argc, const char **argv, const char *prefix)
+static void ensure_core_worktree(const char *path)
 {
-       const char *path;
        const char *cw;
        struct repository subrepo;
 
-       if (argc != 2)
-               BUG("submodule--helper ensure-core-worktree <path>");
-
-       path = argv[1];
-
        if (repo_submodule_init(&subrepo, the_repository, path, null_oid()))
                die(_("could not get a repository handle for submodule '%s'"), path);
 
@@ -2813,8 +2807,6 @@ static int ensure_core_worktree(int argc, const char **argv, const char *prefix)
                free(abs_path);
                strbuf_release(&sb);
        }
-
-       return 0;
 }
 
 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)
 /* NEEDSWORK: this is a temporary name until we delete update_submodule() */
 static int update_submodule2(struct update_data *update_data)
 {
+       ensure_core_worktree(update_data->sm_path);
        if (update_data->just_cloned)
                oidcpy(&update_data->suboid, null_oid());
        else if (resolve_gitlink_ref(update_data->sm_path, "HEAD", &update_data->suboid))
@@ -3459,7 +3452,6 @@ static struct cmd_struct commands[] = {
        {"add", module_add, SUPPORT_SUPER_PREFIX},
        {"update-clone", update_clone, 0},
        {"run-update-procedure", run_update_procedure, 0},
-       {"ensure-core-worktree", ensure_core_worktree, 0},
        {"relative-path", resolve_relative_path, 0},
        {"resolve-relative-url-test", resolve_relative_url_test, 0},
        {"foreach", module_foreach, SUPPORT_SUPER_PREFIX},
index 16dea0ca596b81e86d63ce6451487025a5891188..51be7c7f7e14ec504e3a13a6e7fa323b3b1160f3 100755 (executable)
@@ -385,8 +385,6 @@ cmd_update()
        do
                die_if_unmatched "$quickabort" "$sha1"
 
-               git submodule--helper ensure-core-worktree "$sm_path" || exit 1
-
                displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
 
                if test $just_cloned -eq 0