Skip to content

Commit c9d2562

Browse files
chooglengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 104744f commit c9d2562

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

builtin/submodule--helper.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,12 @@ static int update_clone(int argc, const char **argv, const char *prefix)
25452545
};
25462546

25472547
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>...]"),
25492554
NULL
25502555
};
25512556
suc.prefix = prefix;
@@ -2556,6 +2561,19 @@ static int update_clone(int argc, const char **argv, const char *prefix)
25562561
memset(&filter_options, 0, sizeof(filter_options));
25572562
argc = parse_options(argc, argv, prefix, module_update_clone_options,
25582563
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+
25592577
suc.filter_options = &filter_options;
25602578

25612579
if (update)

git-submodule.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,6 @@ cmd_update()
356356
shift
357357
done
358358

359-
if test -n "$filter" && test "$init" != "1"
360-
then
361-
usage
362-
fi
363-
364359
{
365360
git ${wt_prefix:+-C "$wt_prefix"} submodule--helper update-clone \
366361
${GIT_QUIET:+--quiet} \

0 commit comments

Comments
 (0)