clone: make it possible to specify --tags
Option --no-tags was added in 0dab2468ee
(clone: add a --no-tags option
to clone without tags, 2017-04-26). At the time there was no need to
support --tags as well, although there was some conversation about
it[1].
To simplify the code and to prepare for future commits, invert the flag
internally. Functionally there is no change, because the flag is
default-enabled passing `--tags` has no effect, so there's no need to
add tests for this.
[1]: https://lore.kernel.org/git/CAGZ79kbHuMpiavJ90kQLEL_AR0BEyArcZoEWAjPPhOFacN16YQ@mail.gmail.com/
Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
parent
7f420a6bda
commit
bc26f7690a
|
@ -13,7 +13,7 @@ git clone [--template=<template-directory>]
|
||||||
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
|
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
|
||||||
[-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
|
[-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
|
||||||
[--dissociate] [--separate-git-dir <git-dir>]
|
[--dissociate] [--separate-git-dir <git-dir>]
|
||||||
[--depth <depth>] [--[no-]single-branch] [--no-tags]
|
[--depth <depth>] [--[no-]single-branch] [--[no-]tags]
|
||||||
[--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules]
|
[--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules]
|
||||||
[--[no-]remote-submodules] [--jobs <n>] [--sparse] [--[no-]reject-shallow]
|
[--[no-]remote-submodules] [--jobs <n>] [--sparse] [--[no-]reject-shallow]
|
||||||
[--filter=<filter-spec>] [--also-filter-submodules]] [--] <repository>
|
[--filter=<filter-spec>] [--also-filter-submodules]] [--] <repository>
|
||||||
|
@ -273,12 +273,15 @@ corresponding `--mirror` and `--no-tags` options instead.
|
||||||
branch when `--single-branch` clone was made, no remote-tracking
|
branch when `--single-branch` clone was made, no remote-tracking
|
||||||
branch is created.
|
branch is created.
|
||||||
|
|
||||||
`--no-tags`::
|
`--[no-]tags`::
|
||||||
Don't clone any tags, and set
|
Control whether or not tags will be cloned. When `--no-tags` is
|
||||||
`remote.<remote>.tagOpt=--no-tags` in the config, ensuring
|
given, the option will be become permanent by setting the
|
||||||
that future `git pull` and `git fetch` operations won't follow
|
`remote.<remote>.tagOpt=--no-tags` configuration. This ensures that
|
||||||
any tags. Subsequent explicit tag fetches will still work,
|
future `git pull` and `git fetch` won't follow any tags. Subsequent
|
||||||
(see linkgit:git-fetch[1]).
|
explicit tag fetches will still work (see linkgit:git-fetch[1]).
|
||||||
|
|
||||||
|
By default, tags are cloned and passing `--tags` is thus typically a
|
||||||
|
no-op, unless it cancels out a previous `--no-tags`.
|
||||||
+
|
+
|
||||||
Can be used in conjunction with `--single-branch` to clone and
|
Can be used in conjunction with `--single-branch` to clone and
|
||||||
maintain a branch with no references other than a single cloned
|
maintain a branch with no references other than a single cloned
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1;
|
static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1;
|
||||||
static int option_local = -1, option_no_hardlinks, option_shared;
|
static int option_local = -1, option_no_hardlinks, option_shared;
|
||||||
static int option_no_tags;
|
static int option_tags = 1; /* default enabled */
|
||||||
static int option_shallow_submodules;
|
static int option_shallow_submodules;
|
||||||
static int config_reject_shallow = -1; /* unspecified */
|
static int config_reject_shallow = -1; /* unspecified */
|
||||||
static char *remote_name = NULL;
|
static char *remote_name = NULL;
|
||||||
|
@ -470,7 +470,7 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
|
||||||
get_fetch_map(refs, &refspec->items[i], &tail, 0);
|
get_fetch_map(refs, &refspec->items[i], &tail, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!option_mirror && !option_single_branch && !option_no_tags)
|
if (!option_mirror && !option_single_branch && option_tags)
|
||||||
get_fetch_map(refs, &tag_refspec, &tail, 0);
|
get_fetch_map(refs, &tag_refspec, &tail, 0);
|
||||||
|
|
||||||
refspec_item_clear(&tag_refspec);
|
refspec_item_clear(&tag_refspec);
|
||||||
|
@ -562,7 +562,7 @@ static void update_remote_refs(const struct ref *refs,
|
||||||
|
|
||||||
if (refs) {
|
if (refs) {
|
||||||
write_remote_refs(mapped_refs);
|
write_remote_refs(mapped_refs);
|
||||||
if (option_single_branch && !option_no_tags)
|
if (option_single_branch && option_tags)
|
||||||
write_followtags(refs, msg);
|
write_followtags(refs, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -964,8 +964,8 @@ int cmd_clone(int argc,
|
||||||
N_("deepen history of shallow clone, excluding ref")),
|
N_("deepen history of shallow clone, excluding ref")),
|
||||||
OPT_BOOL(0, "single-branch", &option_single_branch,
|
OPT_BOOL(0, "single-branch", &option_single_branch,
|
||||||
N_("clone only one branch, HEAD or --branch")),
|
N_("clone only one branch, HEAD or --branch")),
|
||||||
OPT_BOOL(0, "no-tags", &option_no_tags,
|
OPT_BOOL(0, "tags", &option_tags,
|
||||||
N_("don't clone any tags, and make later fetches not to follow them")),
|
N_("clone tags, and make later fetches not to follow them")),
|
||||||
OPT_BOOL(0, "shallow-submodules", &option_shallow_submodules,
|
OPT_BOOL(0, "shallow-submodules", &option_shallow_submodules,
|
||||||
N_("any cloned submodules will be shallow")),
|
N_("any cloned submodules will be shallow")),
|
||||||
OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
|
OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
|
||||||
|
@ -1296,7 +1296,7 @@ int cmd_clone(int argc,
|
||||||
git_config_set(key.buf, repo);
|
git_config_set(key.buf, repo);
|
||||||
strbuf_reset(&key);
|
strbuf_reset(&key);
|
||||||
|
|
||||||
if (option_no_tags) {
|
if (!option_tags) {
|
||||||
strbuf_addf(&key, "remote.%s.tagOpt", remote_name);
|
strbuf_addf(&key, "remote.%s.tagOpt", remote_name);
|
||||||
git_config_set(key.buf, "--no-tags");
|
git_config_set(key.buf, "--no-tags");
|
||||||
strbuf_reset(&key);
|
strbuf_reset(&key);
|
||||||
|
@ -1389,7 +1389,7 @@ int cmd_clone(int argc,
|
||||||
if (option_branch)
|
if (option_branch)
|
||||||
expand_ref_prefix(&transport_ls_refs_options.ref_prefixes,
|
expand_ref_prefix(&transport_ls_refs_options.ref_prefixes,
|
||||||
option_branch);
|
option_branch);
|
||||||
if (!option_no_tags)
|
if (option_tags)
|
||||||
strvec_push(&transport_ls_refs_options.ref_prefixes,
|
strvec_push(&transport_ls_refs_options.ref_prefixes,
|
||||||
"refs/tags/");
|
"refs/tags/");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue