submodule--helper update-clone: check for --filter and --init
"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>
Glen Choo committed
Mar 4, 2022 at 16:14 UTC
c9d256249375c7b8a1773139791448860b5789ff
2 files changed
+19
-6
builtin/submodule--helper.c
+19
-1
@@ -2545,7 +2545,12 @@ static int update_clone(int argc, const char **argv, const char *prefix)
2545
};
2546
2547
const char *const git_submodule_helper_usage[] = {
2548
- N_("git submodule--helper update-clone [--prefix=<path>] [<path>...]"),
2548
+ N_("git submodule [--quiet] update"
2549
+ " [--init [--filter=<filter-spec>]] [--remote]"
2550
+ " [-N|--no-fetch] [-f|--force]"
2551
+ " [--checkout|--merge|--rebase]"
2552
+ " [--[no-]recommend-shallow] [--reference <repository>]"
2553
+ " [--recursive] [--[no-]single-branch] [--] [<path>...]"),
2554
NULL
2555
};
2556
suc.prefix = prefix;
@@ -2556,6 +2561,19 @@ static int update_clone(int argc, const char **argv, const char *prefix)
2561
memset(&filter_options, 0, sizeof(filter_options));
2562
argc = parse_options(argc, argv, prefix, module_update_clone_options,
2563
git_submodule_helper_usage, 0);
2564
+
2565
+ if (filter_options.choice && !suc.init) {
2566
+ /*
2567
+ * NEEDSWORK: Don't use usage_with_options() because the
2568
+ * usage string is for "git submodule update", but the
2569
+ * options are for "git submodule--helper update-clone".
2570
+ *
2571
+ * This will no longer be an issue when "update-clone"
2572
+ * is replaced by "git submodule--helper update".
2573
+ */
2574
+ usage(git_submodule_helper_usage[0]);
2575
+ }
2576
+
2577
suc.filter_options = &filter_options;
2578
2579
if (update)
git-submodule.sh
-5
@@ -356,11 +356,6 @@ cmd_update()
356
shift
357
done
358
359
- if test -n "$filter" && test "$init" != "1"
360
- then
361
- usage
362
- fi
363
-
359
{
360
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update-clone \
361
${GIT_QUIET:+--quiet} \