@matheusbsbs / matheus-bagliano / commits / b35ddf41ee
Fork 0

make prune report removed objects on -v

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> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Michael J Gruber committed Sep 29, 2008 at 18:49 UTC b35ddf41eeee1465c9c5a34357664d22b929b79a
2 files changed +11 -4
Documentation/git-prune.txt
+4 -1
@@ -8,7 +8,7 @@ git-prune - Prune all unreachable objects from the object database
8
9 SYNOPSIS
10 --------
11 -'git-prune' [-n] [--expire <expire>] [--] [<head>...]
11 +'git-prune' [-n] [-v] [--expire <expire>] [--] [<head>...]
12
13 DESCRIPTION
14 -----------
@@ -34,6 +34,9 @@ OPTIONS
34 Do not remove anything; just report what it would
35 remove.
36
37 +-v::
38 + Report all removed objects.
39 +
40 \--::
41 Do not interpret any more arguments as options.
42
builtin-prune.c
+7 -3
@@ -7,10 +7,11 @@
7 #include "parse-options.h"
8
9 static const char * const prune_usage[] = {
10 - "git prune [-n] [--expire <time>] [--] [<head>...]",
10 + "git prune [-n] [-v] [--expire <time>] [--] [<head>...]",
11 NULL
12 };
13 static int show_only;
14 +static int verbose;
15 static unsigned long expire;
16
17 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
40 if (st.st_mtime > expire)
41 return 0;
42 }
42 - if (show_only) {
43 + if (show_only || verbose) {
44 enum object_type type = sha1_object_info(sha1, NULL);
45 printf("%s %s\n", sha1_to_hex(sha1),
46 (type > 0) ? typename(type) : "unknown");
46 - } else
47 + }
48 + if (!show_only)
49 unlink(fullpath);
50 return 0;
51 }
@@ -135,6 +137,8 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
137 const struct option options[] = {
138 OPT_BOOLEAN('n', NULL, &show_only,
139 "do not remove, show only"),
140 + OPT_BOOLEAN('v', NULL, &verbose,
141 + "report pruned objects"),
142 OPT_DATE(0, "expire", &expire,
143 "expire objects older than <time>"),
144 OPT_END()