diff options
author | Derrick Stolee <stolee@gmail.com> | 2024-09-06 22:21:41 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-09-06 23:13:48 +0200 |
commit | ce31b82ca95ba13aba424a1e3d09a292637f6f1d (patch) | |
tree | e92748b798dc8a61647d545614e80fabdb6609f7 /scalar.c | |
parent | The twelfth batch (diff) | |
download | git-ce31b82ca95ba13aba424a1e3d09a292637f6f1d.tar.xz git-ce31b82ca95ba13aba424a1e3d09a292637f6f1d.zip |
scalar: add --no-tags option to 'scalar clone'
Some large repositories use tags to track a huge list of release
versions. While this choice is costly on the ref advertisement, it is
further wasteful for clients who do not need those tags. Allow clients
to optionally skip the tag advertisement.
This behavior is similar to that of 'git clone --no-tags' implemented in
0dab2468ee5 (clone: add a --no-tags option to clone without tags,
2017-04-26), including the modification of the remote.origin.tagOpt
config value to include "--no-tags".
One thing that is opposite of the 'git clone' implementation is that
this allows '--tags' as an assumed option, which can be naturally negated
with '--no-tags'. The clone command does not accept '--tags' but allows
"--no-no-tags" as the negation of its '--no-tags' option.
While testing this option, combine the test with the previously untested
'--no-src' option introduced in 4527db8ff8c (scalar: add --[no-]src
option, 2023-08-28).
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'scalar.c')
-rw-r--r-- | scalar.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -410,7 +410,7 @@ static int cmd_clone(int argc, const char **argv) { const char *branch = NULL; int full_clone = 0, single_branch = 0, show_progress = isatty(2); - int src = 1; + int src = 1, tags = 1; struct option clone_options[] = { OPT_STRING('b', "branch", &branch, N_("<branch>"), N_("branch to checkout after clone")), @@ -421,11 +421,13 @@ static int cmd_clone(int argc, const char **argv) "be checked out")), OPT_BOOL(0, "src", &src, N_("create repository within 'src' directory")), + OPT_BOOL(0, "tags", &tags, + N_("specify if tags should be fetched during clone")), OPT_END(), }; const char * const clone_usage[] = { N_("scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]\n" - "\t[--[no-]src] <url> [<enlistment>]"), + "\t[--[no-]src] [--[no-]tags] <url> [<enlistment>]"), NULL }; const char *url; @@ -504,6 +506,11 @@ static int cmd_clone(int argc, const char **argv) goto cleanup; } + if (!tags && set_config("remote.origin.tagOpt=--no-tags")) { + res = error(_("could not disable tags in '%s'"), dir); + goto cleanup; + } + if (!full_clone && (res = run_git("sparse-checkout", "init", "--cone", NULL))) goto cleanup; @@ -513,7 +520,9 @@ static int cmd_clone(int argc, const char **argv) if ((res = run_git("fetch", "--quiet", show_progress ? "--progress" : "--no-progress", - "origin", NULL))) { + "origin", + (tags ? NULL : "--no-tags"), + NULL))) { warning(_("partial clone failed; attempting full clone")); if (set_config("remote.origin.promisor") || |