This option specifies the minimum age of an object before it may be removed by prune. The default value is 24 hours and may be changed using gc.pruneexpire. Signed-off-by: Matthias Lederhofer <matled@gmx.net> --- Shawn O. Pearce <spearce@spearce.org> wrote:Ah, git repack -a -d is safe now too? Thanks for the advice, this is much better than specifying seconds. Here is the new version. Things I'm not sure about, any further comments/discussion? - default value for gc.pruneexpire - special value(s) for gc.pruneexpire/--expire which mean 'do not check for the age', currently it is 'off' --- builtin-prune.c | 31 ++++++++++++++++++++++++++++++- 1 files changed, 30 insertions(+), 1 deletions(-) diff --git a/builtin-prune.c b/builtin-prune.c index 6f0ba0d..410b3b2 100644 --- a/builtin-prune.c +++ b/builtin-prune.c @@ -5,8 +5,9 @@ #include "builtin.h" #include "reachable.h" -static const char prune_usage[] = "git-prune [-n]"; +static const char prune_usage[] = "git-prune [-n] [--expire=time]"; static int show_only; +static int prune_expire; static int prune_object(char *path, const char *filename, const unsigned char *sha1) { @@ -38,6 +39,7 @@ static int prune_dir(int i, char *path) char name[100]; unsigned char sha1[20]; int len = strlen(de->d_name); + struct stat st; switch (len) { case 2: @@ -60,6 +62,11 @@ static int prune_dir(int i, char *path) if (lookup_object(sha1)) continue; + if (prune_expire > 0 && + !stat(mkpath("%s/%s", path, de->d_name), &st) && + st.st_mtime > prune_expire) + continue; + prune_object(path, de->d_name, sha1); continue; } @@ -79,10 +86,25 @@ static void prune_object_dir(const char *path) } } +static int git_prune_config(const char *var, const char *value) +{ + if (!strcmp(var, "gc.pruneexpire")) { + if (!strcmp(value, "off")) + prune_expire = 0; + else + prune_expire = approxidate(value); + return 0; + } + return git_default_config(var, value); +} + int cmd_prune(int argc, const char **argv, const char *prefix) { int i; struct rev_info revs; + prune_expire = time(NULL)-24*60*60; + + git_config(git_prune_config); for (i = 1; i < argc; i++) { const char *arg = argv[i]; @@ -90,6 +112,13 @@ int cmd_prune(int argc, const char **argv, const char *prefix) show_only = 1; continue; } + if (!strncmp(arg, "--expire=", 9)) { + if (!strcmp(arg+9, "off")) + prune_expire = 0; + else + prune_expire = approxidate(arg+9); + continue; + } usage(prune_usage); } -- 1.4.4.4 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| David Woodhouse | Re: [PATCH] bnx2 - use request_firmware() |
| James Bottomley | Re: Integration of SCST in the mainstream Linux kernel |
| Zdenek Kabelac | Problem: Out of memory after 2days with 2GB RAM |
| Florian Schmidt | blacklist kernel boot option |
git: | |
| Junio C Hamano | Re: git-show, was Re: What's in git.git (stable) |
| Daniel Berlin | git annotate runs out of memory |
| Eric Lesh | Re: .gitlink for Summer of Code |
| Petko Manolov | git and binary files |
| Jim Winstead Jr. | Re: Root Disk/Book Disk Compatibility |
| Doug Evans | Re: Stabilizing Linux |
| drew | Re: Linux-0.12 |
| Stephen Pierce | SLS |
| Richard Stallman | Re: Real men don't attack straw men |
| Vim Visual | lenovo x61s bsd.mp Obsd 4.2 difficulties et al. |
| Anselm R. Garbe | OpenBSD 4.0 / Xorg -> vesa 1920x1200 widescreen resolution |
| Parvinder Bhasin | BIND and CNAME-ing |
