prune: handle --progress/no-progress
And have "git gc" pass no-progress when quiet. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Nov 8, 2011 at 00:34 UTC
bf0a59b3872211eaa6d4cebb23ae110522458625
2 files changed
+12
-3
builtin/gc.c
+3
-1
@@ -32,7 +32,7 @@ static const char *prune_expire = "2.weeks.ago";
32
static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
33
static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL};
34
static const char *argv_repack[MAX_ADD] = {"repack", "-d", "-l", NULL};
35
-static const char *argv_prune[] = {"prune", "--expire", NULL, NULL};
35
+static const char *argv_prune[] = {"prune", "--expire", NULL, NULL, NULL};
36
static const char *argv_rerere[] = {"rerere", "gc", NULL};
37
38
static int gc_config(const char *var, const char *value, void *cb)
@@ -243,6 +243,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
243
244
if (prune_expire) {
245
argv_prune[2] = prune_expire;
246
+ if (quiet)
247
+ argv_prune[3] = "--no-progress";
248
if (run_command_v_opt(argv_prune, RUN_GIT_CMD))
249
return error(FAILED_RUN, argv_prune[0]);
250
}
builtin/prune.c
+9
-2
@@ -15,6 +15,7 @@ static const char * const prune_usage[] = {
15
static int show_only;
16
static int verbose;
17
static unsigned long expire;
18
+static int show_progress = -1;
19
20
static int prune_tmp_object(const char *path, const char *filename)
21
{
@@ -125,10 +126,11 @@ static void remove_temporary_files(const char *path)
126
int cmd_prune(int argc, const char **argv, const char *prefix)
127
{
128
struct rev_info revs;
128
- struct progress *progress;
129
+ struct progress *progress = NULL;
130
const struct option options[] = {
131
OPT__DRY_RUN(&show_only, "do not remove, show only"),
132
OPT__VERBOSE(&verbose, "report pruned objects"),
133
+ OPT_BOOL(0, "progress", &show_progress, "show progress"),
134
OPT_DATE(0, "expire", &expire,
135
"expire objects older than <time>"),
136
OPT_END()
@@ -154,7 +156,12 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
156
else
157
die("unrecognized argument: %s", name);
158
}
157
- progress = start_progress_delay("Checking connectivity", 0, 0, 2);
159
+
160
+ if (show_progress == -1)
161
+ show_progress = isatty(2);
162
+ if (show_progress)
163
+ progress = start_progress_delay("Checking connectivity", 0, 0, 2);
164
+
165
mark_reachable_objects(&revs, 1, progress);
166
stop_progress(&progress);
167
prune_object_dir(get_object_directory());