git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] make prune report removed objects on -v
@ 2008-09-29 16:49 Michael J Gruber
  0 siblings, 0 replies; only message in thread
From: Michael J Gruber @ 2008-09-29 16:49 UTC (permalink / raw)
  To: git; +Cc: Michael J Gruber

This adds an option "-v" which makes "git prune" more verbose:
It outputs all removed objects while removing them.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/git-prune.txt |    5 ++++-
 builtin-prune.c             |   10 +++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt
index 54f1dab..da6055d 100644
--- a/Documentation/git-prune.txt
+++ b/Documentation/git-prune.txt
@@ -8,7 +8,7 @@ git-prune - Prune all unreachable objects from the object database
 
 SYNOPSIS
 --------
-'git-prune' [-n] [--expire <expire>] [--] [<head>...]
+'git-prune' [-n] [-v] [--expire <expire>] [--] [<head>...]
 
 DESCRIPTION
 -----------
@@ -34,6 +34,9 @@ OPTIONS
 	Do not remove anything; just report what it would
 	remove.
 
+-v::
+	Report all removed objects.
+
 \--::
 	Do not interpret any more arguments as options.
 
diff --git a/builtin-prune.c b/builtin-prune.c
index 1663f8b..7b4ec80 100644
--- a/builtin-prune.c
+++ b/builtin-prune.c
@@ -7,10 +7,11 @@
 #include "parse-options.h"
 
 static const char * const prune_usage[] = {
-	"git prune [-n] [--expire <time>] [--] [<head>...]",
+	"git prune [-n] [-v] [--expire <time>] [--] [<head>...]",
 	NULL
 };
 static int show_only;
+static int verbose;
 static unsigned long expire;
 
 static int prune_tmp_object(const char *path, const char *filename)
@@ -39,11 +40,12 @@ static int prune_object(char *path, const char *filename, const unsigned char *s
 		if (st.st_mtime > expire)
 			return 0;
 	}
-	if (show_only) {
+	if (show_only || verbose) {
 		enum object_type type = sha1_object_info(sha1, NULL);
 		printf("%s %s\n", sha1_to_hex(sha1),
 		       (type > 0) ? typename(type) : "unknown");
-	} else
+	}
+	if (!show_only)
 		unlink(fullpath);
 	return 0;
 }
@@ -135,6 +137,8 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 	const struct option options[] = {
 		OPT_BOOLEAN('n', NULL, &show_only,
 			    "do not remove, show only"),
+		OPT_BOOLEAN('v', NULL, &verbose,
+			"report pruned objects"),
 		OPT_DATE(0, "expire", &expire,
 			 "expire objects older than <time>"),
 		OPT_END()
-- 
1.6.0.2.287.g3791f

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-29 16:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-29 16:49 [PATCH] make prune report removed objects on -v Michael J Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).