Skip to content

Commit

Permalink
Merge branch 'mg/verboseprune'
Browse files Browse the repository at this point in the history
* mg/verboseprune:
  make prune report removed objects on -v
  • Loading branch information
Shawn O. Pearce committed Oct 9, 2008
2 parents 6355364 + b35ddf4 commit e4fff5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Documentation/git-prune.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand All @@ -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.

Expand Down
10 changes: 7 additions & 3 deletions builtin-prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e4fff5c

Please sign in to comment.