login
Header Space

 
 

[PATCH] prune: --expire=time

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Shawn O. Pearce <spearce@...>
Cc: <git@...>
Date: Friday, January 19, 2007 - 6:49 am

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
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] prune-packed: new option --min-age=N, Matthias Lederhofer, (Thu Jan 18, 1:18 pm)
Re: [PATCH] prune-packed: new option --min-age=N, Shawn O. Pearce, (Thu Jan 18, 1:24 pm)
Re: [PATCH] prune-packed: new option --min-age=N, Matthias Lederhofer, (Thu Jan 18, 1:42 pm)
Re: [PATCH] prune-packed: new option --min-age=N, Shawn O. Pearce, (Thu Jan 18, 1:51 pm)
[RFC] prune: --expire=seconds, Matthias Lederhofer, (Thu Jan 18, 6:29 pm)
Re: [RFC] prune: --expire=seconds, Junio C Hamano, (Thu Jan 18, 6:32 pm)
Re: [RFC] prune: --expire=seconds, Shawn O. Pearce, (Thu Jan 18, 11:44 pm)
[PATCH] prune: --expire=time, Matthias Lederhofer, (Fri Jan 19, 6:49 am)
Re: [PATCH] prune: --expire=time, Junio C Hamano, (Fri Jan 19, 3:18 pm)
Re: [PATCH] prune: --expire=time, Simon 'corecode' Schubert..., (Sat Jan 20, 8:06 am)
Re: [PATCH] prune: --expire=time, Matthias Lederhofer, (Sat Jan 20, 7:18 am)
Re: [PATCH] prune: --expire=time, Junio C Hamano, (Sun Jan 21, 2:55 am)
Re: [PATCH] prune: --expire=time, Matthias Lederhofer, (Sun Jan 21, 6:37 am)
Re: [PATCH] prune: --expire=time, Junio C Hamano, (Sun Jan 21, 7:17 am)
Re: [PATCH] prune: --expire=time, Jeff King, (Sun Jan 21, 6:01 pm)
Re: [PATCH] prune: --expire=time, Steven Grimm, (Sun Jan 21, 9:38 pm)
Re: [PATCH] prune: --expire=time, Junio C Hamano, (Sun Jan 21, 10:03 pm)
Re: [PATCH] prune: --expire=time, Jeff King, (Sun Jan 21, 9:52 pm)
Re: [PATCH] prune: --expire=time, Junio C Hamano, (Sun Jan 21, 10:06 pm)
Re: [PATCH] prune: --expire=time, Linus Torvalds, (Sun Jan 21, 10:23 pm)
Re: [PATCH] prune: --expire=time, Junio C Hamano, (Sun Jan 21, 10:40 pm)
[PATCH] v1.5.0.txt: update description of git-gc, Jeff King, (Sun Jan 21, 11:26 pm)
Re: [PATCH] prune: --expire=time, Linus Torvalds, (Sun Jan 21, 10:58 pm)
Re: [PATCH] prune: --expire=time, Junio C Hamano, (Mon Jan 22, 1:17 am)
Re: [PATCH] prune: --expire=time, Linus Torvalds, (Mon Jan 22, 2:26 am)
Re: [PATCH] prune: --expire=time, Junio C Hamano, (Mon Jan 22, 3:12 am)
Re: [PATCH] prune: --expire=time, Shawn O. Pearce, (Mon Jan 22, 2:57 am)
Re: [PATCH] prune: --expire=time, Shawn O. Pearce, (Sun Jan 21, 3:53 am)
Re: [PATCH] prune: --expire=time, Nicolas Pitre, (Fri Jan 19, 11:41 am)
speck-geostationary