diff options
Diffstat (limited to 'builtin/prune.c')
-rw-r--r-- | builtin/prune.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/builtin/prune.c b/builtin/prune.c index 8f4f052285..4cfec82f40 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -8,12 +8,12 @@ #include "progress.h" static const char * const prune_usage[] = { - N_("git prune [-n] [-v] [--expire <time>] [--] [<head>...]"), + N_("git prune [-n] [-v] [--progress] [--expire <time>] [--] [<head>...]"), NULL }; static int show_only; static int verbose; -static unsigned long expire; +static timestamp_t expire; static int show_progress = -1; static int prune_tmp_file(const char *fullpath) @@ -30,7 +30,7 @@ static int prune_tmp_file(const char *fullpath) return 0; } -static int prune_object(const unsigned char *sha1, const char *fullpath, +static int prune_object(const struct object_id *oid, const char *fullpath, void *data) { struct stat st; @@ -39,7 +39,7 @@ static int prune_object(const unsigned char *sha1, const char *fullpath, * Do we know about this object? * It must have been reachable */ - if (lookup_object(sha1)) + if (lookup_object(oid->hash)) return 0; if (lstat(fullpath, &st)) { @@ -50,8 +50,8 @@ static int prune_object(const unsigned char *sha1, const char *fullpath, if (st.st_mtime > expire) return 0; if (show_only || verbose) { - enum object_type type = sha1_object_info(sha1, NULL); - printf("%s %s\n", sha1_to_hex(sha1), + enum object_type type = sha1_object_info(oid->hash, NULL); + printf("%s %s\n", oid_to_hex(oid), (type > 0) ? typename(type) : "unknown"); } if (!show_only) @@ -68,7 +68,7 @@ static int prune_cruft(const char *basename, const char *path, void *data) return 0; } -static int prune_subdir(int nr, const char *path, void *data) +static int prune_subdir(unsigned int nr, const char *path, void *data) { if (!show_only) rmdir(path); @@ -101,17 +101,20 @@ int cmd_prune(int argc, const char **argv, const char *prefix) { struct rev_info revs; struct progress *progress = NULL; + int exclude_promisor_objects = 0; const struct option options[] = { OPT__DRY_RUN(&show_only, N_("do not remove, show only")), OPT__VERBOSE(&verbose, N_("report pruned objects")), OPT_BOOL(0, "progress", &show_progress, N_("show progress")), OPT_EXPIRY_DATE(0, "expire", &expire, N_("expire objects older than <time>")), + OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects, + N_("limit traversal to objects outside promisor packfiles")), OPT_END() }; char *s; - expire = ULONG_MAX; + expire = TIME_MAX; save_commit_buffer = 0; check_replace_refs = 0; ref_paranoia = 1; @@ -123,11 +126,12 @@ int cmd_prune(int argc, const char **argv, const char *prefix) die(_("cannot prune in a precious-objects repo")); while (argc--) { - unsigned char sha1[20]; + struct object_id oid; const char *name = *argv++; - if (!get_sha1(name, sha1)) { - struct object *object = parse_object_or_die(sha1, name); + if (!get_oid(name, &oid)) { + struct object *object = parse_object_or_die(&oid, + name); add_pending_object(&revs, object, ""); } else @@ -137,7 +141,11 @@ int cmd_prune(int argc, const char **argv, const char *prefix) if (show_progress == -1) show_progress = isatty(2); if (show_progress) - progress = start_progress_delay(_("Checking connectivity"), 0, 0, 2); + progress = start_delayed_progress(_("Checking connectivity"), 0); + if (exclude_promisor_objects) { + fetch_if_missing = 0; + revs.exclude_promisor_objects = 1; + } mark_reachable_objects(&revs, 1, expire, progress); stop_progress(&progress); |