diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2009-02-14 23:10:10 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-02-14 21:14:07 -0800 |
commit | 58e9d9d472ff4dbc6cfbf7459878778c739395eb (patch) | |
tree | 6a09b2564916644ee5f0a18cf70d51936fe6802b /t | |
parent | e9cc02f0e41fd5d2f51e3c3f2b4f8cfa9e434432 (diff) | |
download | git-58e9d9d472ff4dbc6cfbf7459878778c739395eb.tar.gz git-58e9d9d472ff4dbc6cfbf7459878778c739395eb.tar.xz |
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')
-rwxr-xr-x | t/t5304-prune.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index 771c0a06a..55ed7c793 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 |