summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-09-17 18:11:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-17 18:30:05 (GMT)
commit3ddaad0e06035a752c9010dcd5094b37262080fb (patch)
tree98d25f3096405ddac2685bf270ef0ff22f4208ff /builtin
parent2057d75038541cd16debb1c55f3f897fd244965c (diff)
downloadgit-3ddaad0e06035a752c9010dcd5094b37262080fb.zip
git-3ddaad0e06035a752c9010dcd5094b37262080fb.tar.gz
git-3ddaad0e06035a752c9010dcd5094b37262080fb.tar.bz2
maintenance: add --quiet option
Maintenance activities are commonly used as steps in larger scripts. Providing a '--quiet' option allows those scripts to be less noisy when run on a terminal window. Turn this mode on by default when stderr is not a terminal. Pipe the option to the 'git gc' child process. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/gc.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index ec064e8..bacce0c 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -701,12 +701,13 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
}
static const char * const builtin_maintenance_run_usage[] = {
- N_("git maintenance run [--auto]"),
+ N_("git maintenance run [--auto] [--[no-]quiet]"),
NULL
};
struct maintenance_run_opts {
int auto_flag;
+ int quiet;
};
static int maintenance_task_gc(struct maintenance_run_opts *opts)
@@ -718,6 +719,10 @@ static int maintenance_task_gc(struct maintenance_run_opts *opts)
if (opts->auto_flag)
strvec_push(&child.args, "--auto");
+ if (opts->quiet)
+ strvec_push(&child.args, "--quiet");
+ else
+ strvec_push(&child.args, "--no-quiet");
close_object_store(the_repository->objects);
return run_command(&child);
@@ -729,10 +734,14 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
struct option builtin_maintenance_run_options[] = {
OPT_BOOL(0, "auto", &opts.auto_flag,
N_("run tasks based on the state of the repository")),
+ OPT_BOOL(0, "quiet", &opts.quiet,
+ N_("do not report progress or other information over stderr")),
OPT_END()
};
memset(&opts, 0, sizeof(opts));
+ opts.quiet = !isatty(2);
+
argc = parse_options(argc, argv, prefix,
builtin_maintenance_run_options,
builtin_maintenance_run_usage,