test local clone by copying
Test the effect of an earlier change by f7835a2 (preserve mtime of local clone, 2009-09-12) to keep stale loose object files stale in the new repository when a local clone is made by copying files in .git/ directory. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Clemens Buchacher committed
Sep 13, 2009 at 12:49 UTC
98df233e2d7d815b1f2e2e253b9d6c6ce1bfe58f
1 file changed
+33
-21
t/t5304-prune.sh
+33
-21
@@ -6,6 +6,17 @@
6
test_description='prune'
7
. ./test-lib.sh
8
9
+day=$((60*60*24))
10
+week=$(($day*7))
11
+
12
+add_blob() {
13
+ before=$(git count-objects | sed "s/ .*//") &&
14
+ BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
15
+ BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
16
+ test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
17
+ test -f $BLOB_FILE
18
+}
19
+
20
test_expect_success setup '
21
22
: > file &&
@@ -31,11 +42,7 @@ test_expect_success 'prune stale packs' '
42
43
test_expect_success 'prune --expire' '
44
34
- before=$(git count-objects | sed "s/ .*//") &&
35
- BLOB=$(echo aleph | git hash-object -w --stdin) &&
36
- BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
37
- test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
38
- test -f $BLOB_FILE &&
45
+ add_blob &&
46
git prune --expire=1.hour.ago &&
47
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
48
test -f $BLOB_FILE &&
@@ -48,16 +55,12 @@ test_expect_success 'prune --expire' '
55
56
test_expect_success 'gc: implicit prune --expire' '
57
51
- before=$(git count-objects | sed "s/ .*//") &&
52
- BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
53
- BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
54
- test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
55
- test -f $BLOB_FILE &&
56
- test-chmtime =-$((86400*14-30)) $BLOB_FILE &&
58
+ add_blob &&
59
+ test-chmtime =-$((2*$week-30)) $BLOB_FILE &&
60
git gc &&
61
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
62
test -f $BLOB_FILE &&
60
- test-chmtime =-$((86400*14+1)) $BLOB_FILE &&
63
+ test-chmtime =-$((2*$week+1)) $BLOB_FILE &&
64
git gc &&
65
test $before = $(git count-objects | sed "s/ .*//") &&
66
! test -f $BLOB_FILE
@@ -114,12 +117,8 @@ test_expect_success 'prune: do not prune heads listed as an argument' '
117
118
test_expect_success 'gc --no-prune' '
119
117
- before=$(git count-objects | sed "s/ .*//") &&
118
- BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
119
- BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
120
- test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
121
- test -f $BLOB_FILE &&
122
- test-chmtime =-$((86400*5001)) $BLOB_FILE &&
120
+ add_blob &&
121
+ test-chmtime =-$((5001*$day)) $BLOB_FILE &&
122
git config gc.pruneExpire 2.days.ago &&
123
git gc --no-prune &&
124
test 1 = $(git count-objects | sed "s/ .*//") &&
@@ -140,9 +139,8 @@ test_expect_success 'gc respects gc.pruneExpire' '
139
140
test_expect_success 'gc --prune=<date>' '
141
143
- BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
144
- BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
145
- test-chmtime =-$((86400*5001)) $BLOB_FILE &&
142
+ add_blob &&
143
+ test-chmtime =-$((5001*$day)) $BLOB_FILE &&
144
git gc --prune=5002.days.ago &&
145
test -f $BLOB_FILE &&
146
git gc --prune=5000.days.ago &&
@@ -150,4 +148,18 @@ test_expect_success 'gc --prune=<date>' '
148
149
'
150
151
+test_expect_success 'gc: prune old objects after local clone' '
152
+ add_blob &&
153
+ test-chmtime =-$((2*$week+1)) $BLOB_FILE &&
154
+ git clone --no-hardlinks . aclone &&
155
+ (
156
+ cd aclone &&
157
+ test 1 = $(git count-objects | sed "s/ .*//") &&
158
+ test -f $BLOB_FILE &&
159
+ git gc --prune &&
160
+ test 0 = $(git count-objects | sed "s/ .*//") &&
161
+ ! test -f $BLOB_FILE
162
+ )
163
+'
164
+
165
test_done