3 # Copyright (c) 2007 Junio C Hamano
6 test_description
='Test prune and reflog expiration'
13 eval "o=\$$N" && git cat-file
-t $o ||
{
23 output
=$
(git fsck-objects
--full)
28 echo "$output" |
grep "$1" ;;
33 aa
=${1%??????????????????????????????????????} zz
=${1#??}
34 mv .git
/objects
/$aa/$zz .git
/$aa$zz
38 aa
=${1%??????????????????????????????????????} zz
=${1#??}
39 mkdir
-p .git
/objects
/$aa
40 mv .git
/$aa$zz .git
/objects
/$aa/$zz
48 git cat-file
-t $o && {
57 test_expect_success setup
'
64 test_tick && git commit -m rabbit &&
65 H=`git rev-parse --verify HEAD` &&
66 A=`git rev-parse --verify HEAD:A` &&
67 B=`git rev-parse --verify HEAD:A/B` &&
68 C=`git rev-parse --verify HEAD:C` &&
69 D=`git rev-parse --verify HEAD:A/D` &&
70 E=`git rev-parse --verify HEAD:A/B/E` &&
75 test_tick && git commit -m dragon &&
76 L=`git rev-parse --verify HEAD` &&
83 test_tick && git commit -a -m sheep &&
84 F=`git rev-parse --verify HEAD:F` &&
85 G=`git rev-parse --verify HEAD:A/G` &&
86 I=`git rev-parse --verify HEAD:A` &&
87 J=`git rev-parse --verify HEAD` &&
91 test_tick && git commit -a -m monkey &&
92 K=`git rev-parse --verify HEAD` &&
95 check_have A B C D E F G H I J K L &&
99 check_have A B C D E F G H I J K L &&
103 loglen=$(wc -l <.git/logs/refs/heads/master) &&
107 test_expect_success rewind
'
108 test_tick && git reset --hard HEAD~2 &&
114 check_have A B C D E F G H I J K L &&
118 check_have A B C D E F G H I J K L &&
120 loglen=$(wc -l <.git/logs/refs/heads/master) &&
124 test_expect_success
'corrupt and check' '
127 check_fsck "missing blob $F"
131 test_expect_success
'reflog expire --dry-run should not touch reflog' '
133 git reflog expire --dry-run \
134 --expire=$(($test_tick - 10000)) \
135 --expire-unreachable=$(($test_tick - 10000)) \
139 loglen=$(wc -l <.git/logs/refs/heads/master) &&
142 check_fsck "missing blob $F"
145 test_expect_success
'reflog expire' '
147 git reflog expire --verbose \
148 --expire=$(($test_tick - 10000)) \
149 --expire-unreachable=$(($test_tick - 10000)) \
153 loglen=$(wc -l <.git/logs/refs/heads/master) &&
156 check_fsck "dangling commit $K"
159 test_expect_success
'prune and fsck' '
164 check_have A B C D E H L &&
165 check_dont_have F G I J K
169 test_expect_success
'recover and check' '
172 check_fsck "dangling blob $F"