Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalar: add --no-tags option #1780

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Documentation/scalar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ cloning. If the HEAD at the remote did not point at any branch when
`<entlistment>/src` directory. Use `--no-src` to place the cloned
repository directly in the `<enlistment>` directory.

--[no-]tags::
By default, `scalar clone` will fetch the tag objects advertised by
the remote and future `git fetch` commands will do the same. Use
`--no-tags` to avoid fetching tags in `scalar clone` and to configure
the repository to avoid fetching tags in the future. To fetch tags after
cloning with `--no-tags`, run `git fetch --tags`.

--[no-]full-clone::
A sparse-checkout is initialized by default. This behavior can be
turned off via `--full-clone`.
Expand Down
15 changes: 12 additions & 3 deletions scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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") ||
Expand Down
18 changes: 18 additions & 0 deletions t/t9210-scalar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,24 @@ test_expect_success 'scalar clone' '
)
'

test_expect_success 'scalar clone --no-... opts' '
# Note: redirect stderr always to avoid having a verbose test
# run result in a difference in the --[no-]progress option.
GIT_TRACE2_EVENT="$(pwd)/no-opt-trace" scalar clone \
--no-tags --no-src \
"file://$(pwd)" no-opts --single-branch 2>/dev/null &&

test_subcommand git fetch --quiet --no-progress \
origin --no-tags <no-opt-trace &&
(
cd no-opts &&

test_cmp_config --no-tags remote.origin.tagopt &&
git for-each-ref --format="%(refname)" refs/tags/ >tags &&
test_line_count = 0 tags
)
'

test_expect_success 'scalar reconfigure' '
git init one/src &&
scalar register one &&
Expand Down
Loading