Skip to content

Commit 4527db8

Browse files
derrickstoleegitster
authored andcommitted
scalar: add --[no-]src option
Some users have strong aversions to Scalar's opinion that the repository should be in a 'src' directory, even though this creates a clean slate for placing build artifacts in adjacent directories. The new --no-src option allows users to opt out of the default behavior. While adding options, make sure the usage output by 'scalar clone -h' reports the same as the SYNOPSIS line in Documentation/scalar.txt. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb7d80e commit 4527db8

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Documentation/scalar.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ scalar - A tool for managing large Git repositories
88
SYNOPSIS
99
--------
1010
[verse]
11-
scalar clone [--single-branch] [--branch <main-branch>] [--full-clone] <url> [<enlistment>]
11+
scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]
12+
[--[no-]src] <url> [<enlistment>]
1213
scalar list
1314
scalar register [<enlistment>]
1415
scalar unregister [<enlistment>]
@@ -80,6 +81,11 @@ remote-tracking branch for the branch this option was used for the initial
8081
cloning. If the HEAD at the remote did not point at any branch when
8182
`--single-branch` clone was made, no remote-tracking branch is created.
8283

84+
--[no-]src::
85+
By default, `scalar clone` places the cloned repository within a
86+
`<entlistment>/src` directory. Use `--no-src` to place the cloned
87+
repository directly in the `<enlistment>` directory.
88+
8389
--[no-]full-clone::
8490
A sparse-checkout is initialized by default. This behavior can be
8591
turned off via `--full-clone`.

scalar.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ static int cmd_clone(int argc, const char **argv)
409409
{
410410
const char *branch = NULL;
411411
int full_clone = 0, single_branch = 0, show_progress = isatty(2);
412+
int src = 1;
412413
struct option clone_options[] = {
413414
OPT_STRING('b', "branch", &branch, N_("<branch>"),
414415
N_("branch to checkout after clone")),
@@ -417,10 +418,13 @@ static int cmd_clone(int argc, const char **argv)
417418
OPT_BOOL(0, "single-branch", &single_branch,
418419
N_("only download metadata for the branch that will "
419420
"be checked out")),
421+
OPT_BOOL(0, "src", &src,
422+
N_("create repository within 'src' directory")),
420423
OPT_END(),
421424
};
422425
const char * const clone_usage[] = {
423-
N_("scalar clone [<options>] [--] <repo> [<dir>]"),
426+
N_("scalar clone [--single-branch] [--branch <main-branch>] [--full-clone]\n"
427+
"\t[--[no-]src] <url> [<enlistment>]"),
424428
NULL
425429
};
426430
const char *url;
@@ -456,7 +460,10 @@ static int cmd_clone(int argc, const char **argv)
456460
if (is_directory(enlistment))
457461
die(_("directory '%s' exists already"), enlistment);
458462

459-
dir = xstrfmt("%s/src", enlistment);
463+
if (src)
464+
dir = xstrfmt("%s/src", enlistment);
465+
else
466+
dir = xstrdup(enlistment);
460467

461468
strbuf_reset(&buf);
462469
if (branch)

t/t9211-scalar-clone.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,16 @@ test_expect_success 'scalar clone warns when background maintenance fails' '
180180
grep "could not turn on maintenance" err
181181
'
182182

183+
test_expect_success '`scalar clone --no-src`' '
184+
scalar clone --src "file://$(pwd)/to-clone" with-src &&
185+
scalar clone --no-src "file://$(pwd)/to-clone" without-src &&
186+
187+
test_path_is_dir with-src/src &&
188+
test_path_is_missing without-src/src &&
189+
190+
(cd with-src/src && ls ?*) >with &&
191+
(cd without-src && ls ?*) >without &&
192+
test_cmp with without
193+
'
194+
183195
test_done

0 commit comments

Comments
 (0)