Skip to content

Commit 98df233

Browse files
Clemens Buchachergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 65d15ed commit 98df233

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

t/t5304-prune.sh

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
test_description='prune'
77
. ./test-lib.sh
88

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+
920
test_expect_success setup '
1021
1122
: > file &&
@@ -31,11 +42,7 @@ test_expect_success 'prune stale packs' '
3142

3243
test_expect_success 'prune --expire' '
3344
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 &&
3946
git prune --expire=1.hour.ago &&
4047
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
4148
test -f $BLOB_FILE &&
@@ -48,16 +55,12 @@ test_expect_success 'prune --expire' '
4855

4956
test_expect_success 'gc: implicit prune --expire' '
5057
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 &&
5760
git gc &&
5861
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
5962
test -f $BLOB_FILE &&
60-
test-chmtime =-$((86400*14+1)) $BLOB_FILE &&
63+
test-chmtime =-$((2*$week+1)) $BLOB_FILE &&
6164
git gc &&
6265
test $before = $(git count-objects | sed "s/ .*//") &&
6366
! test -f $BLOB_FILE
@@ -114,12 +117,8 @@ test_expect_success 'prune: do not prune heads listed as an argument' '
114117

115118
test_expect_success 'gc --no-prune' '
116119
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 &&
123122
git config gc.pruneExpire 2.days.ago &&
124123
git gc --no-prune &&
125124
test 1 = $(git count-objects | sed "s/ .*//") &&
@@ -140,14 +139,27 @@ test_expect_success 'gc respects gc.pruneExpire' '
140139

141140
test_expect_success 'gc --prune=<date>' '
142141
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 &&
146144
git gc --prune=5002.days.ago &&
147145
test -f $BLOB_FILE &&
148146
git gc --prune=5000.days.ago &&
149147
test ! -f $BLOB_FILE
150148
151149
'
152150

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+
153165
test_done

0 commit comments

Comments
 (0)