All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Lederhofer <matled@gmx.net>
To: git@vger.kernel.org
Cc: "Shawn O. Pearce" <spearce@spearce.org>
Subject: [RFC] prune: --expire=seconds
Date: Thu, 18 Jan 2007 23:29:19 +0100	[thread overview]
Message-ID: <20070118222919.GA22060@moooo.ath.cx> (raw)
In-Reply-To: <20070118175134.GH15428@spearce.org>

This option specifies the minimum age of an object before it
may be removed by prune.  The default value is 2 hours and
may be changed using gc.pruneexpire.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
Shawn O. Pearce <spearce@spearce.org> wrote:
> If you are going to implement this I would suggest making the default
> age 2 hours and allow the user to configure it from a gc.pruneexpire
> configuration option, much like gc.reflogexpire.

Here it is, I've set the default value to 2 hours as you suggested.
Any other comments if the default should be a value >0 or 0 to keep
the old behaviour?
---
 builtin-prune.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/builtin-prune.c b/builtin-prune.c
index 6f0ba0d..f46892d 100644
--- a/builtin-prune.c
+++ b/builtin-prune.c
@@ -5,8 +5,10 @@
 #include "builtin.h"
 #include "reachable.h"
 
-static const char prune_usage[] = "git-prune [-n]";
+static const char prune_usage[] = "git-prune [-n] [--expire=seconds]";
 static int show_only;
+static int prune_expire;
+static time_t now;
 
 static int prune_object(char *path, const char *filename, const unsigned char *sha1)
 {
@@ -38,6 +40,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 +63,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) &&
+			    now-st.st_mtime < prune_expire)
+				continue;
+
 			prune_object(path, de->d_name, sha1);
 			continue;
 		}
@@ -79,10 +87,21 @@ static void prune_object_dir(const char *path)
 	}
 }
 
+static void git_prune_config(const char *var, const char *value)
+{
+	if (!strcmp(var, "gc.pruneexpire")) {
+		prune_expire = git_config_int(var, 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 = 2*60*60;
+	now = time(NULL);
 
 	for (i = 1; i < argc; i++) {
 		const char *arg = argv[i];
@@ -90,6 +109,10 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 			show_only = 1;
 			continue;
 		}
+		if (!strncmp(arg, "--expire=", 9)) {
+			prune_expire = atoi(arg+9);
+			continue;
+		}
 		usage(prune_usage);
 	}
 
-- 
1.4.4.4

  reply	other threads:[~2007-01-18 22:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-18 17:18 [PATCH] prune-packed: new option --min-age=N Matthias Lederhofer
2007-01-18 17:24 ` Shawn O. Pearce
2007-01-18 17:42   ` Matthias Lederhofer
2007-01-18 17:51     ` Shawn O. Pearce
2007-01-18 22:29       ` Matthias Lederhofer [this message]
2007-01-18 22:32         ` [RFC] prune: --expire=seconds Junio C Hamano
2007-01-19  3:44           ` Shawn O. Pearce
2007-01-19 10:49             ` [PATCH] prune: --expire=time Matthias Lederhofer
2007-01-19 15:41               ` Nicolas Pitre
2007-01-19 19:18               ` Junio C Hamano
2007-01-20 11:18                 ` Matthias Lederhofer
2007-01-21  6:55                   ` Junio C Hamano
2007-01-21  7:53                     ` Shawn O. Pearce
2007-01-21 10:37                     ` Matthias Lederhofer
2007-01-21 11:17                       ` Junio C Hamano
2007-01-21 22:01                         ` Jeff King
2007-01-22  1:38                           ` Steven Grimm
2007-01-22  1:52                             ` Jeff King
2007-01-22  2:06                               ` Junio C Hamano
2007-01-22  2:23                                 ` Linus Torvalds
2007-01-22  2:40                                   ` Junio C Hamano
2007-01-22  2:58                                     ` Linus Torvalds
2007-01-22  5:17                                       ` Junio C Hamano
2007-01-22  6:26                                         ` Linus Torvalds
2007-01-22  6:57                                           ` Shawn O. Pearce
2007-01-22  7:12                                           ` Junio C Hamano
2007-01-22  9:32                                         ` Jakub Narebski
2007-01-22  3:26                                     ` [PATCH] v1.5.0.txt: update description of git-gc Jeff King
2007-01-22  2:03                             ` [PATCH] prune: --expire=time Junio C Hamano
2007-01-20 12:06                 ` Simon 'corecode' Schubert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070118222919.GA22060@moooo.ath.cx \
    --to=matled@gmx.net \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.