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` &&
74 ( test "`git repo-config --bool core.filemode`" != false ||
75 echo executable >>C ) &&
77 test_tick && git commit -m dragon &&
78 L=`git rev-parse --verify HEAD` &&
85 test_tick && git commit -a -m sheep &&
86 F=`git rev-parse --verify HEAD:F` &&
87 G=`git rev-parse --verify HEAD:A/G` &&
88 I=`git rev-parse --verify HEAD:A` &&
89 J=`git rev-parse --verify HEAD` &&
93 test_tick && git commit -a -m monkey &&
94 K=`git rev-parse --verify HEAD` &&
97 check_have A B C D E F G H I J K L &&
101 check_have A B C D E F G H I J K L &&
105 loglen=$(wc -l <.git/logs/refs/heads/master) &&
109 test_expect_success rewind
'
110 test_tick && git reset --hard HEAD~2 &&
116 check_have A B C D E F G H I J K L &&
120 check_have A B C D E F G H I J K L &&
122 loglen=$(wc -l <.git/logs/refs/heads/master) &&
126 test_expect_success
'corrupt and check' '
129 check_fsck "missing blob $F"
133 test_expect_success
'reflog expire --dry-run should not touch reflog' '
135 git reflog expire --dry-run \
136 --expire=$(($test_tick - 10000)) \
137 --expire-unreachable=$(($test_tick - 10000)) \
141 loglen=$(wc -l <.git/logs/refs/heads/master) &&
144 check_fsck "missing blob $F"
147 test_expect_success
'reflog expire' '
149 git reflog expire --verbose \
150 --expire=$(($test_tick - 10000)) \
151 --expire-unreachable=$(($test_tick - 10000)) \
155 loglen=$(wc -l <.git/logs/refs/heads/master) &&
158 check_fsck "dangling commit $K"
161 test_expect_success
'prune and fsck' '
166 check_have A B C D E H L &&
167 check_dont_have F G I J K
171 test_expect_success
'recover and check' '
174 check_fsck "dangling blob $F"