Skip to content

Commit 0299251

Browse files
committed
Merge branch 'ds/scalar-no-tags'
The "scalar clone" command learned the "--no-tags" option. * ds/scalar-no-tags: scalar: add --no-tags option to 'scalar clone'
2 parents 57974d4 + ce31b82 commit 0299251

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

Documentation/scalar.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ cloning. If the HEAD at the remote did not point at any branch when
8686
`<entlistment>/src` directory. Use `--no-src` to place the cloned
8787
repository directly in the `<enlistment>` directory.
8888

89+
--[no-]tags::
90+
By default, `scalar clone` will fetch the tag objects advertised by
91+
the remote and future `git fetch` commands will do the same. Use
92+
`--no-tags` to avoid fetching tags in `scalar clone` and to configure
93+
the repository to avoid fetching tags in the future. To fetch tags after
94+
cloning with `--no-tags`, run `git fetch --tags`.
95+
8996
--[no-]full-clone::
9097
A sparse-checkout is initialized by default. This behavior can be
9198
turned off via `--full-clone`.

scalar.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static int cmd_clone(int argc, const char **argv)
410410
{
411411
const char *branch = NULL;
412412
int full_clone = 0, single_branch = 0, show_progress = isatty(2);
413-
int src = 1;
413+
int src = 1, tags = 1;
414414
struct option clone_options[] = {
415415
OPT_STRING('b', "branch", &branch, N_("<branch>"),
416416
N_("branch to checkout after clone")),
@@ -421,11 +421,13 @@ static int cmd_clone(int argc, const char **argv)
421421
"be checked out")),
422422
OPT_BOOL(0, "src", &src,
423423
N_("create repository within 'src' directory")),
424+
OPT_BOOL(0, "tags", &tags,
425+
N_("specify if tags should be fetched during clone")),
424426
OPT_END(),
425427
};
426428
const char * const clone_usage[] = {
427429
N_("scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]\n"
428-
"\t[--[no-]src] <url> [<enlistment>]"),
430+
"\t[--[no-]src] [--[no-]tags] <url> [<enlistment>]"),
429431
NULL
430432
};
431433
const char *url;
@@ -504,6 +506,11 @@ static int cmd_clone(int argc, const char **argv)
504506
goto cleanup;
505507
}
506508

509+
if (!tags && set_config("remote.origin.tagOpt=--no-tags")) {
510+
res = error(_("could not disable tags in '%s'"), dir);
511+
goto cleanup;
512+
}
513+
507514
if (!full_clone &&
508515
(res = run_git("sparse-checkout", "init", "--cone", NULL)))
509516
goto cleanup;
@@ -513,7 +520,9 @@ static int cmd_clone(int argc, const char **argv)
513520

514521
if ((res = run_git("fetch", "--quiet",
515522
show_progress ? "--progress" : "--no-progress",
516-
"origin", NULL))) {
523+
"origin",
524+
(tags ? NULL : "--no-tags"),
525+
NULL))) {
517526
warning(_("partial clone failed; attempting full clone"));
518527

519528
if (set_config("remote.origin.promisor") ||

t/t9210-scalar.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,24 @@ test_expect_success 'scalar clone' '
169169
)
170170
'
171171

172+
test_expect_success 'scalar clone --no-... opts' '
173+
# Note: redirect stderr always to avoid having a verbose test
174+
# run result in a difference in the --[no-]progress option.
175+
GIT_TRACE2_EVENT="$(pwd)/no-opt-trace" scalar clone \
176+
--no-tags --no-src \
177+
"file://$(pwd)" no-opts --single-branch 2>/dev/null &&
178+
179+
test_subcommand git fetch --quiet --no-progress \
180+
origin --no-tags <no-opt-trace &&
181+
(
182+
cd no-opts &&
183+
184+
test_cmp_config --no-tags remote.origin.tagopt &&
185+
git for-each-ref --format="%(refname)" refs/tags/ >tags &&
186+
test_line_count = 0 tags
187+
)
188+
'
189+
172190
test_expect_success 'scalar reconfigure' '
173191
git init one/src &&
174192
scalar register one &&

0 commit comments

Comments
 (0)