summaryrefslogtreecommitdiff
path: root/t/t5304-prune.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2009-02-14 23:10:10 +0100
committerJunio C Hamano <gitster@pobox.com>2009-02-14 21:14:07 -0800
commit58e9d9d472ff4dbc6cfbf7459878778c739395eb (patch)
tree6a09b2564916644ee5f0a18cf70d51936fe6802b /t/t5304-prune.sh
parente9cc02f0e41fd5d2f51e3c3f2b4f8cfa9e434432 (diff)
downloadgit-58e9d9d472ff4dbc6cfbf7459878778c739395eb.tar.gz
gc: make --prune useful again by accepting an optional parameter
With this patch, "git gc --no-prune" will not prune any loose (and dangling) object, and "git gc --prune=5.minutes.ago" will prune all loose objects older than 5 minutes. This patch benefitted from suggestions by Thomas Rast and Jan Krï¿œger. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5304-prune.sh')
-rwxr-xr-xt/t5304-prune.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index 771c0a06a4..55ed7c7935 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -112,4 +112,42 @@ test_expect_success 'prune: do not prune heads listed as an argument' '
'
+test_expect_success 'gc --no-prune' '
+
+ before=$(git count-objects | sed "s/ .*//") &&
+ BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
+ BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
+ test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
+ test -f $BLOB_FILE &&
+ test-chmtime =-$((86400*5001)) $BLOB_FILE &&
+ git config gc.pruneExpire 2.days.ago &&
+ git gc --no-prune &&
+ test 1 = $(git count-objects | sed "s/ .*//") &&
+ test -f $BLOB_FILE
+
+'
+
+test_expect_success 'gc respects gc.pruneExpire' '
+
+ git config gc.pruneExpire 5002.days.ago &&
+ git gc &&
+ test -f $BLOB_FILE &&
+ git config gc.pruneExpire 5000.days.ago &&
+ git gc &&
+ test ! -f $BLOB_FILE
+
+'
+
+test_expect_success 'gc --prune=<date>' '
+
+ BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
+ BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
+ test-chmtime =-$((86400*5001)) $BLOB_FILE &&
+ git gc --prune=5002.days.ago &&
+ test -f $BLOB_FILE &&
+ git gc --prune=5000.days.ago &&
+ test ! -f $BLOB_FILE
+
+'
+
test_done