summaryrefslogtreecommitdiff
path: root/builtin-prune.c
diff options
context:
space:
mode:
authorAdam Simpkins <simpkins@facebook.com>2010-02-27 03:50:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-02-28 18:28:05 (GMT)
commitcbf731ed4ec511f2c32598e03d7865f35881fea2 (patch)
treedc54c7b061bdb678c045a74d40255417bdfa7393 /builtin-prune.c
parent64da6e20de1f2246e2d8d9d85e53ca3cbf393212 (diff)
downloadgit-cbf731ed4ec511f2c32598e03d7865f35881fea2.zip
git-cbf731ed4ec511f2c32598e03d7865f35881fea2.tar.gz
git-cbf731ed4ec511f2c32598e03d7865f35881fea2.tar.bz2
prune: honor --expire=never
Previously, prune treated an expiration time of 0 to mean that no expire argument was supplied, and everything should be pruned. As a result, "prune --expire=never" would prune all unreachable objects, regardless of their timestamp. prune can be called with --expire=never automatically by gc, when the gc.pruneExpire configuration is set to "never". Signed-off-by: Adam Simpkins <simpkins@facebook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-prune.c')
-rw-r--r--builtin-prune.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/builtin-prune.c b/builtin-prune.c
index 4675f60..81f915ec 100644
--- a/builtin-prune.c
+++ b/builtin-prune.c
@@ -18,13 +18,11 @@ static unsigned long expire;
static int prune_tmp_object(const char *path, const char *filename)
{
const char *fullpath = mkpath("%s/%s", path, filename);
- if (expire) {
- struct stat st;
- if (lstat(fullpath, &st))
- return error("Could not stat '%s'", fullpath);
- if (st.st_mtime > expire)
- return 0;
- }
+ struct stat st;
+ if (lstat(fullpath, &st))
+ return error("Could not stat '%s'", fullpath);
+ if (st.st_mtime > expire)
+ return 0;
printf("Removing stale temporary file %s\n", fullpath);
if (!show_only)
unlink_or_warn(fullpath);
@@ -34,13 +32,11 @@ static int prune_tmp_object(const char *path, const char *filename)
static int prune_object(char *path, const char *filename, const unsigned char *sha1)
{
const char *fullpath = mkpath("%s/%s", path, filename);
- if (expire) {
- struct stat st;
- if (lstat(fullpath, &st))
- return error("Could not stat '%s'", fullpath);
- if (st.st_mtime > expire)
- return 0;
- }
+ struct stat st;
+ if (lstat(fullpath, &st))
+ return error("Could not stat '%s'", 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),
@@ -139,6 +135,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
};
char *s;
+ expire = ULONG_MAX;
save_commit_buffer = 0;
read_replace_refs = 0;
init_revisions(&revs, prefix);