summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a6c7306)
raw | patch | inline | side by side (parent: a6c7306)
author | Matthias Lederhofer <matled@gmx.net> | |
Fri, 19 Jan 2007 10:49:35 +0000 (11:49 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 21 Jan 2007 07:29:49 +0000 (23:29 -0800) |
This option gives grace period to objects that are unreachable
from the refs from getting pruned.
The default value is 24 hours and may be changed using
gc.prunegrace.
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
from the refs from getting pruned.
The default value is 24 hours and may be changed using
gc.prunegrace.
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
index a11e3030943ab3ffd10afa017640826795809d05..fbd344da4028b76bb6f2bbb1401fe836624d0403 100644 (file)
SYNOPSIS
--------
-'git-prune' [-n] [--] [<head>...]
+'git-prune' [-n] [--grace=<time>]
DESCRIPTION
-----------
Do not remove anything; just report what it would
remove.
+--grace=<time>::
+ Do not prune loose objects that are younger than the
+ specified time. This gives a grace period to newly
+ created objects from getting pruned.
+
+////////////////////////////////////////////
\--::
Do not interpret any more arguments as options.
------------
$ git prune $(cd ../another && $(git-rev-parse --all))
------------
+////////////////////////////////////////////
Author
------
diff --git a/builtin-prune.c b/builtin-prune.c
index 6f0ba0d04d789f17e3f0136a3591a9465af7e71d..7929af1aacd515bcc49bb79e9e3d8ee616397b4f 100644 (file)
--- a/builtin-prune.c
+++ b/builtin-prune.c
#include "builtin.h"
#include "reachable.h"
-static const char prune_usage[] = "git-prune [-n]";
+static const char prune_usage[] = "git-prune [-n] [--grace=time]";
static int show_only;
+static int prune_grace_period;
static int prune_object(char *path, const char *filename, const unsigned char *sha1)
{
char name[100];
unsigned char sha1[20];
int len = strlen(de->d_name);
+ struct stat st;
switch (len) {
case 2:
if (lookup_object(sha1))
continue;
+ if (prune_grace_period > 0 &&
+ !stat(mkpath("%s/%s", path, de->d_name), &st) &&
+ st.st_mtime > prune_grace_period)
+ continue;
+
prune_object(path, de->d_name, sha1);
continue;
}
}
}
+static int git_prune_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "gc.prunegrace")) {
+ if (!strcmp(value, "off"))
+ prune_grace_period = 0;
+ else
+ prune_grace_period = 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_grace_period = time(NULL)-24*60*60;
+
+ git_config(git_prune_config);
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
show_only = 1;
continue;
}
+ if (!strncmp(arg, "--grace=", 8)) {
+ if (!strcmp(arg+8, "off"))
+ prune_grace_period = 0;
+ else
+ prune_grace_period = approxidate(arg+8);
+ continue;
+ }
usage(prune_usage);
}
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 8e8d526ef2e68fb8f50b9164f2ff032bafa104d6..0c435f957489b011623d320411dbc619163f80a9 100755 (executable)
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
check_have A B C D E F G H I J K L &&
- git prune &&
+ git prune --grace=off &&
check_have A B C D E F G H I J K L &&
check_have A B C D E F G H I J K L &&
- git prune &&
+ git prune --grace=off &&
check_have A B C D E F G H I J K L &&
test_expect_success 'prune and fsck' '
- git prune &&
+ git prune --grace=off &&
check_fsck &&
check_have A B C D E H L &&
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 2c151912a3bcf2c91cfafcbc22f11bc71fedd34d..2a55d5ae3206d056f87310d85e5ee5436437ae23 100755 (executable)
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
test_expect_success 'pack the source repository' '
git repack -a -d &&
- git prune
+ git prune --grace=off
'
test_expect_success 'pack the destination repository' '
cd victim &&
git repack -a -d &&
- git prune &&
+ git prune --grace=off &&
cd ..
'
index dd9caad1c2a34a6721aafa1840916a5a7471ece8..ab00e8fb6a2e3ce77cace23e95fd5f6923a1a932 100755 (executable)
git add file2 &&
git commit -m addition &&
git repack -a -d &&
-git prune'
+git prune --grace=off'
cd "$base_dir"
git add file3 &&
git commit -m update &&
git repack -a -d &&
-git prune'
+git prune --grace=off'
cd "$base_dir"
index b9f6d9636313c29cb9d9553ca908e623fdefd179..c30fee81f5eb282798b6ca4abc4bd777f262080a 100755 (executable)
git add file1 &&
git commit -m "Initial commit" file1 &&
git repack -a -d &&
-git prune'
+git prune --grace=off'
cd "$base_dir"
git add file2 &&
git commit -m "next commit" file2 &&
git repack -a -d -l &&
-git prune'
+git prune --grace=off'
cd "$base_dir"
git add file3 &&
git commit -m "one more" file3 &&
git repack -a -d -l &&
-git prune'
+git prune --grace=off'
cd "$base_dir"