]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper update-clone: check for --filter and --init
authorGlen Choo <chooglen@google.com>
Sat, 5 Mar 2022 00:14:01 +0000 (16:14 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 5 Mar 2022 00:39:13 +0000 (16:39 -0800)
"git submodule update --filter" also requires the "--init" option. Teach
update-clone to do this usage check in C and remove the check from
git-submodule.sh.

In addition, change update-clone's usage string so that it teaches users
about "git submodule update" instead of "git submodule--helper
update-clone" (the string is copied from git-submodule.sh). This should
be more helpful to users since they don't invoke update-clone directly.

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 296ab80bf27c30217be348bbcb3591d80efd6e47..bef9ab22d42e03aaeaa33c605165bb6ad26ad15f 100644 (file)
@@ -2545,7 +2545,12 @@ static int update_clone(int argc, const char **argv, const char *prefix)
        };
 
        const char *const git_submodule_helper_usage[] = {
-               N_("git submodule--helper update-clone [--prefix=<path>] [<path>...]"),
+               N_("git submodule [--quiet] update"
+               " [--init [--filter=<filter-spec>]] [--remote]"
+               " [-N|--no-fetch] [-f|--force]"
+               " [--checkout|--merge|--rebase]"
+               " [--[no-]recommend-shallow] [--reference <repository>]"
+               " [--recursive] [--[no-]single-branch] [--] [<path>...]"),
                NULL
        };
        suc.prefix = prefix;
@@ -2556,6 +2561,19 @@ static int update_clone(int argc, const char **argv, const char *prefix)
        memset(&filter_options, 0, sizeof(filter_options));
        argc = parse_options(argc, argv, prefix, module_update_clone_options,
                             git_submodule_helper_usage, 0);
+
+       if (filter_options.choice && !suc.init) {
+               /*
+                * NEEDSWORK: Don't use usage_with_options() because the
+                * usage string is for "git submodule update", but the
+                * options are for "git submodule--helper update-clone".
+                *
+                * This will no longer be an issue when "update-clone"
+                * is replaced by "git submodule--helper update".
+                */
+               usage(git_submodule_helper_usage[0]);
+       }
+
        suc.filter_options = &filter_options;
 
        if (update)
index 51be7c7f7e14ec504e3a13a6e7fa323b3b1160f3..aa8bdfca9def032152e613730e416e5f8243d167 100755 (executable)
@@ -356,11 +356,6 @@ cmd_update()
                shift
        done
 
-       if test -n "$filter" && test "$init" != "1"
-       then
-               usage
-       fi
-
        {
        git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update-clone \
                ${GIT_QUIET:+--quiet} \