mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
worktree: add --quiet option
Add the '--quiet' option to git worktree, as for the other git commands. 'add' is the only command affected by it since all other commands, except 'list', are currently silent by default. [jc: appiled trivial fix-up to keep the tests from touching outside the scratch area] Helped-by: Martin Ågren <martin.agren@gmail.com> Helped-by: Duy Nguyen <pclouds@gmail.com> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Elia Pinto <gitter.spiros@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
63749b2dea
commit
371979c217
|
@ -173,6 +173,10 @@ This can also be set up as the default behaviour by using the
|
||||||
This format will remain stable across Git versions and regardless of user
|
This format will remain stable across Git versions and regardless of user
|
||||||
configuration. See below for details.
|
configuration. See below for details.
|
||||||
|
|
||||||
|
-q::
|
||||||
|
--quiet::
|
||||||
|
With 'add', suppress feedback messages.
|
||||||
|
|
||||||
-v::
|
-v::
|
||||||
--verbose::
|
--verbose::
|
||||||
With `prune`, report all removals.
|
With `prune`, report all removals.
|
||||||
|
|
|
@ -27,6 +27,7 @@ static const char * const worktree_usage[] = {
|
||||||
struct add_opts {
|
struct add_opts {
|
||||||
int force;
|
int force;
|
||||||
int detach;
|
int detach;
|
||||||
|
int quiet;
|
||||||
int checkout;
|
int checkout;
|
||||||
int keep_locked;
|
int keep_locked;
|
||||||
};
|
};
|
||||||
|
@ -303,9 +304,13 @@ static int add_worktree(const char *path, const char *refname,
|
||||||
if (!is_branch)
|
if (!is_branch)
|
||||||
argv_array_pushl(&cp.args, "update-ref", "HEAD",
|
argv_array_pushl(&cp.args, "update-ref", "HEAD",
|
||||||
oid_to_hex(&commit->object.oid), NULL);
|
oid_to_hex(&commit->object.oid), NULL);
|
||||||
else
|
else {
|
||||||
argv_array_pushl(&cp.args, "symbolic-ref", "HEAD",
|
argv_array_pushl(&cp.args, "symbolic-ref", "HEAD",
|
||||||
symref.buf, NULL);
|
symref.buf, NULL);
|
||||||
|
if (opts->quiet)
|
||||||
|
argv_array_push(&cp.args, "--quiet");
|
||||||
|
}
|
||||||
|
|
||||||
cp.env = child_env.argv;
|
cp.env = child_env.argv;
|
||||||
ret = run_command(&cp);
|
ret = run_command(&cp);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -315,6 +320,8 @@ static int add_worktree(const char *path, const char *refname,
|
||||||
cp.argv = NULL;
|
cp.argv = NULL;
|
||||||
argv_array_clear(&cp.args);
|
argv_array_clear(&cp.args);
|
||||||
argv_array_pushl(&cp.args, "reset", "--hard", NULL);
|
argv_array_pushl(&cp.args, "reset", "--hard", NULL);
|
||||||
|
if (opts->quiet)
|
||||||
|
argv_array_push(&cp.args, "--quiet");
|
||||||
cp.env = child_env.argv;
|
cp.env = child_env.argv;
|
||||||
ret = run_command(&cp);
|
ret = run_command(&cp);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -437,6 +444,7 @@ static int add(int ac, const char **av, const char *prefix)
|
||||||
OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named commit")),
|
OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named commit")),
|
||||||
OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")),
|
OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")),
|
||||||
OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working tree locked")),
|
OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working tree locked")),
|
||||||
|
OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
|
||||||
OPT_PASSTHRU(0, "track", &opt_track, NULL,
|
OPT_PASSTHRU(0, "track", &opt_track, NULL,
|
||||||
N_("set up tracking mode (see git-branch(1))"),
|
N_("set up tracking mode (see git-branch(1))"),
|
||||||
PARSE_OPT_NOARG | PARSE_OPT_OPTARG),
|
PARSE_OPT_NOARG | PARSE_OPT_OPTARG),
|
||||||
|
@ -491,8 +499,8 @@ static int add(int ac, const char **av, const char *prefix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!opts.quiet)
|
||||||
print_preparing_worktree_line(opts.detach, branch, new_branch, !!new_branch_force);
|
print_preparing_worktree_line(opts.detach, branch, new_branch, !!new_branch_force);
|
||||||
|
|
||||||
if (new_branch) {
|
if (new_branch) {
|
||||||
struct child_process cp = CHILD_PROCESS_INIT;
|
struct child_process cp = CHILD_PROCESS_INIT;
|
||||||
|
@ -500,6 +508,8 @@ static int add(int ac, const char **av, const char *prefix)
|
||||||
argv_array_push(&cp.args, "branch");
|
argv_array_push(&cp.args, "branch");
|
||||||
if (new_branch_force)
|
if (new_branch_force)
|
||||||
argv_array_push(&cp.args, "--force");
|
argv_array_push(&cp.args, "--force");
|
||||||
|
if (opts.quiet)
|
||||||
|
argv_array_push(&cp.args, "--quiet");
|
||||||
argv_array_push(&cp.args, new_branch);
|
argv_array_push(&cp.args, new_branch);
|
||||||
argv_array_push(&cp.args, branch);
|
argv_array_push(&cp.args, branch);
|
||||||
if (opt_track)
|
if (opt_track)
|
||||||
|
|
|
@ -252,6 +252,11 @@ test_expect_success 'add -B' '
|
||||||
test_cmp_rev master^ poodle
|
test_cmp_rev master^ poodle
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'add --quiet' '
|
||||||
|
git worktree add --quiet another-worktree master 2>actual &&
|
||||||
|
test_must_be_empty actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'local clone from linked checkout' '
|
test_expect_success 'local clone from linked checkout' '
|
||||||
git clone --local here here-clone &&
|
git clone --local here here-clone &&
|
||||||
( cd here-clone && git fsck )
|
( cd here-clone && git fsck )
|
||||||
|
|
Loading…
Reference in a new issue