git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] prune: handle --progress/no-progress

From
Jeff King <peff@peff.net>
Date
Nov 8, 2011, 05:34 UTC
Message-ID
<20111108053407.GA16852@sigill.intra.peff.net>
In-Reply-To
<20111108053149.GA29643@sigill.intra.peff.net>
And have "git gc" pass no-progress when quiet.
Signed-off-by: Jeff King <peff@peff.net>
---
On top of the prune progress patch you sent earlier.

I did these as separate patches so you could see each change, but I'd also be fine if they are just squashed into your patch.

 builtin/gc.c    |    4 +++-
 builtin/prune.c |   11 +++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index 0498094..271376d 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -32,7 +32,7 @@
 static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
 static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL};
 static const char *argv_repack[MAX_ADD] = {"repack", "-d", "-l", NULL};
-static const char *argv_prune[] = {"prune", "--expire", NULL, NULL};
+static const char *argv_prune[] = {"prune", "--expire", NULL, NULL, NULL};
 static const char *argv_rerere[] = {"rerere", "gc", NULL};
 
 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)
 
 	if (prune_expire) {
 		argv_prune[2] = prune_expire;
+		if (quiet)
+			argv_prune[3] = "--no-progress";
 		if (run_command_v_opt(argv_prune, RUN_GIT_CMD))
 			return error(FAILED_RUN, argv_prune[0]);
 	}
diff --git a/builtin/prune.c b/builtin/prune.c
index 6b39d3f..58d7cb8 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -15,6 +15,7 @@
 static int show_only;
 static int verbose;
 static unsigned long expire;
+static int show_progress = -1;
 
 static int prune_tmp_object(const char *path, const char *filename)
 {
@@ -125,10 +126,11 @@ static void remove_temporary_files(const char *path)
 int cmd_prune(int argc, const char **argv, const char *prefix)
 {
 	struct rev_info revs;
-	struct progress *progress;
+	struct progress *progress = NULL;
 	const struct option options[] = {
 		OPT__DRY_RUN(&show_only, "do not remove, show only"),
 		OPT__VERBOSE(&verbose, "report pruned objects"),
+		OPT_BOOL(0, "progress", &show_progress, "show progress"),
 		OPT_DATE(0, "expire", &expire,
 			 "expire objects older than <time>"),
 		OPT_END()
@@ -154,7 +156,12 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 		else
 			die("unrecognized argument: %s", name);
 	}
-	progress = start_progress_delay("Checking connectivity", 0, 0, 2);
+
+	if (show_progress == -1)
+		show_progress = isatty(2);
+	if (show_progress)
+		progress = start_progress_delay("Checking connectivity", 0, 0, 2);
+
 	mark_reachable_objects(&revs, 1, progress);
 	stop_progress(&progress);
 	prune_object_dir(get_object_directory());
-- 
1.7.7.2.7.g9f96f.dirty
Previous: Jeff KingNext: Nguyễn Thái Ngọc Duy
Message 3 of 7 in “prune: show progress while marking reachable objects”
  1. prune: show progress while marking reachable objectsNguyễn Thái Ngọc Duy, Nov 5, 2011
  2. Jeff KingNov 8, 2011
  3. 1/2 prune: handle --progress/no-progressJeff King, Nov 8, 2011
  4. prune: handle --progress/no-progressNguyễn Thái Ngọc Duy, Nov 9, 2011
  5. 2/2 reachable: per-object progressJeff King, Nov 8, 2011
  6. Junio C HamanoNov 8, 2011
  7. Nguyen Thai Ngoc DuyNov 9, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.