summaryrefslogtreecommitdiff
path: root/t/t1410-reflog.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-11-29 20:59:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-11-30 23:47:01 (GMT)
commitf01913e4190bed98f918ec575229943a0ee47d83 (patch)
treec04e9f0017668acdb60db48bb4c0dd88cc8606dc /t/t1410-reflog.sh
parent28391a80a94d2b59d1d21f8264fe5dab91d77249 (diff)
downloadgit-f01913e4190bed98f918ec575229943a0ee47d83.zip
git-f01913e4190bed98f918ec575229943a0ee47d83.tar.gz
git-f01913e4190bed98f918ec575229943a0ee47d83.tar.bz2
Add "--expire <time>" option to 'git prune'
Earlier, 'git prune' would prune all loose unreachable objects. This could be quite dangerous, as the objects could be used in an ongoing operation. This patch adds a mode to expire only loose, unreachable objects which are older than a certain time. For example, by git prune --expire 14.days you can prune only those objects which are loose, unreachable and older than 14 days (and thus probably outdated). The implementation uses st.st_mtime rather than st.st_ctime, because it can be tested better, using 'touch -d <time>' (and omitting the test when the platform does not support that command line switch). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1410-reflog.sh')
-rwxr-xr-xt/t1410-reflog.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index e5bbc38..f959aae 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -175,4 +175,22 @@ test_expect_success 'recover and check' '
'
+test_expect_success 'prune --expire' '
+
+ before=$(git count-objects | sed "s/ .*//") &&
+ BLOB=$(echo aleph | 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 &&
+ git reset --hard &&
+ git prune --expire=1.hour.ago &&
+ test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
+ test -f $BLOB_FILE &&
+ test-chmtime -86500 $BLOB_FILE &&
+ git prune --expire 1.day &&
+ test $before = $(git count-objects | sed "s/ .*//") &&
+ ! test -f $BLOB_FILE
+
+'
+
test_done