]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: have --require-init imply --init
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 28 Jun 2022 10:05:27 +0000 (12:05 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Jun 2022 20:13:17 +0000 (13:13 -0700)
Adjust code added in 0060fd1511b (clone --recurse-submodules: prevent
name squatting on Windows, 2019-09-12) to have the internal
--require-init option imply --init, rather than having
"git-submodule.sh" add it implicitly.

This change doesn't make any difference now, but eliminates another
special-case where "git submodule--helper update"'s behavior was
different from "git submodule update". This will make it easier to
eventually replace the cmd_update() function in git-submodule.sh.

We'll still need to keep the distinction between "--init" and
"--require-init" in git-submodule.sh. Once cmd_update() gets
re-implemented in C we'll be able to change variables and other code
related to that, but not yet.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
git-submodule.sh

index 5c77dfcffee65d753f3a650c4d700eec35348236..f0702d0cfa22934a45c9e23c1ba2a3ad439c8ead 100644 (file)
@@ -2618,7 +2618,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
                OPT_BOOL(0, "progress", &opt.progress,
                            N_("force cloning progress")),
                OPT_BOOL(0, "require-init", &opt.require_init,
-                          N_("disallow cloning into non-empty directory")),
+                          N_("disallow cloning into non-empty directory, implies --init")),
                OPT_BOOL(0, "single-branch", &opt.single_branch,
                         N_("clone only one branch, HEAD or --branch")),
                OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
@@ -2642,6 +2642,9 @@ static int module_update(int argc, const char **argv, const char *prefix)
        argc = parse_options(argc, argv, prefix, module_update_options,
                             git_submodule_helper_usage, 0);
 
+       if (opt.require_init)
+               opt.init = 1;
+
        if (filter_options.choice && !opt.init) {
                usage_with_options(git_submodule_helper_usage,
                                   module_update_options);
index 20fc1b620fadd4aeed5df1aa759b740a558b11fc..5b9683bf766388d01984b2dc70be765a29e25077 100755 (executable)
@@ -251,7 +251,6 @@ cmd_update()
                        init=1
                        ;;
                --require-init)
-                       init=1
                        require_init=1
                        ;;
                --remote)