summaryrefslogtreecommitdiff
path: root/prune-packed.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-08-20 04:38:36 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-08-20 04:38:36 (GMT)
commit51890a64eb152fb914d0dd3676f549ab8d8cc49a (patch)
treec5b6dd555899bca32f456418a05a236a38502c4f /prune-packed.c
parent4426ac70a1d15e103bd8a4bd1aa16be16b80c5bc (diff)
downloadgit-51890a64eb152fb914d0dd3676f549ab8d8cc49a.zip
git-51890a64eb152fb914d0dd3676f549ab8d8cc49a.tar.gz
git-51890a64eb152fb914d0dd3676f549ab8d8cc49a.tar.bz2
Call prune-packed from "git prune" as well.
Add -n (dryrun) flag to git-prune-packed, and call it from "git prune". Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'prune-packed.c')
-rw-r--r--prune-packed.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/prune-packed.c b/prune-packed.c
index a2f4488..5306e8e 100644
--- a/prune-packed.c
+++ b/prune-packed.c
@@ -1,6 +1,9 @@
#include "cache.h"
-static const char prune_packed_usage[] = "git-prune-packed (no arguments)";
+static const char prune_packed_usage[] =
+"git-prune-packed [-n]";
+
+static int dryrun;
static void prune_dir(int i, DIR *dir, char *pathname, int len)
{
@@ -18,7 +21,9 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len)
if (!has_sha1_pack(sha1))
continue;
memcpy(pathname + len, de->d_name, 38);
- if (unlink(pathname) < 0)
+ if (dryrun)
+ printf("rm -f %s\n", pathname);
+ else if (unlink(pathname) < 0)
error("unable to unlink %s", pathname);
}
}
@@ -55,8 +60,11 @@ int main(int argc, char **argv)
const char *arg = argv[i];
if (*arg == '-') {
- /* Handle flags here .. */
- usage(prune_packed_usage);
+ if (!strcmp(arg, "-n"))
+ dryrun = 1;
+ else
+ usage(prune_packed_usage);
+ continue;
}
/* Handle arguments here .. */
usage(prune_packed_usage);