tests: remove some direct access to .git/logs
Alternate refs backends might store reflogs somewhere other than .git/logs. Change most test code that directly accesses .git/logs to instead use git reflog commands. There are still a few tests which need direct access to reflogs: to check reflog permissions, to manually create reflogs from scratch, to save/restore reflogs, to check the format of raw reflog data, and to remove not just reflog contents, but the reflogs themselves. All cases which don't need direct access have been modified. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Turner committed
Jul 27, 2015 at 18:57 UTC
d0ab058498cf3f1862de76b419abc0b67fabbd83
10 files changed
+37
-33
t/t1400-update-ref.sh
+2
-3
@@ -155,12 +155,11 @@ test_expect_success "(not) changed .git/$m" "
155
'
156
rm -f .git/$m
157
158
-: a repository with working tree always has reflog these days...
159
-: >.git/logs/refs/heads/master
158
+rm -f .git/logs/refs/heads/master
159
test_expect_success \
160
"create $m (logged by touch)" \
161
'GIT_COMMITTER_DATE="2005-05-26 23:30" \
163
- git update-ref HEAD '"$A"' -m "Initial Creation" &&
162
+ git update-ref --create-reflog HEAD '"$A"' -m "Initial Creation" &&
163
test '"$A"' = $(cat .git/'"$m"')'
164
test_expect_success \
165
"update $m (logged by touch)" \
t/t1410-reflog.sh
+16
-8
@@ -100,7 +100,8 @@ test_expect_success setup '
100
101
check_fsck &&
102
103
- test_line_count = 4 .git/logs/refs/heads/master
103
+ git reflog refs/heads/master >output &&
104
+ test_line_count = 4 output
105
'
106
107
test_expect_success rewind '
@@ -116,7 +117,8 @@ test_expect_success rewind '
117
118
check_have A B C D E F G H I J K L &&
119
119
- test_line_count = 5 .git/logs/refs/heads/master
120
+ git reflog refs/heads/master >output &&
121
+ test_line_count = 5 output
122
'
123
124
test_expect_success 'corrupt and check' '
@@ -134,7 +136,8 @@ test_expect_success 'reflog expire --dry-run should not touch reflog' '
136
--stale-fix \
137
--all &&
138
137
- test_line_count = 5 .git/logs/refs/heads/master &&
139
+ git reflog refs/heads/master >output &&
140
+ test_line_count = 5 output &&
141
142
check_fsck "missing blob $F"
143
'
@@ -147,7 +150,8 @@ test_expect_success 'reflog expire' '
150
--stale-fix \
151
--all &&
152
150
- test_line_count = 2 .git/logs/refs/heads/master &&
153
+ git reflog refs/heads/master >output &&
154
+ test_line_count = 2 output &&
155
156
check_fsck "dangling commit $K"
157
'
@@ -213,7 +217,8 @@ test_expect_success 'delete' '
217
test_expect_success 'rewind2' '
218
219
test_tick && git reset --hard HEAD~2 &&
216
- test_line_count = 4 .git/logs/refs/heads/master
220
+ git reflog refs/heads/master >output &&
221
+ test_line_count = 4 output
222
'
223
224
test_expect_success '--expire=never' '
@@ -222,7 +227,8 @@ test_expect_success '--expire=never' '
227
--expire=never \
228
--expire-unreachable=never \
229
--all &&
225
- test_line_count = 4 .git/logs/refs/heads/master
230
+ git reflog refs/heads/master >output &&
231
+ test_line_count = 4 output
232
'
233
234
test_expect_success 'gc.reflogexpire=never' '
@@ -230,7 +236,8 @@ test_expect_success 'gc.reflogexpire=never' '
236
git config gc.reflogexpire never &&
237
git config gc.reflogexpireunreachable never &&
238
git reflog expire --verbose --all &&
233
- test_line_count = 4 .git/logs/refs/heads/master
239
+ git reflog refs/heads/master >output &&
240
+ test_line_count = 4 output
241
'
242
243
test_expect_success 'gc.reflogexpire=false' '
@@ -238,7 +245,8 @@ test_expect_success 'gc.reflogexpire=false' '
245
git config gc.reflogexpire false &&
246
git config gc.reflogexpireunreachable false &&
247
git reflog expire --verbose --all &&
241
- test_line_count = 4 .git/logs/refs/heads/master &&
248
+ git reflog refs/heads/master >output &&
249
+ test_line_count = 4 output &&
250
251
git config --unset gc.reflogexpire &&
252
git config --unset gc.reflogexpireunreachable
t/t1411-reflog-show.sh
+1
-1
@@ -138,7 +138,7 @@ test_expect_success '--date magic does not override explicit @{0} syntax' '
138
: >expect
139
test_expect_success 'empty reflog file' '
140
git branch empty &&
141
- : >.git/logs/refs/heads/empty &&
141
+ git reflog expire --expire=all refs/heads/empty &&
142
143
git log -g empty >actual &&
144
test_cmp expect actual
t/t1503-rev-parse-verify.sh
+3
-6
@@ -85,8 +85,7 @@ test_expect_success 'fails silently when using -q' '
85
86
test_expect_success 'fails silently when using -q with deleted reflogs' '
87
ref=$(git rev-parse HEAD) &&
88
- : >.git/logs/refs/test &&
89
- git update-ref -m "message for refs/test" refs/test "$ref" &&
88
+ git update-ref --create-reflog -m "message for refs/test" refs/test "$ref" &&
89
git reflog delete --updateref --rewrite refs/test@{0} &&
90
test_must_fail git rev-parse -q --verify refs/test@{0} >error 2>&1 &&
91
test_must_be_empty error
@@ -94,16 +93,14 @@ test_expect_success 'fails silently when using -q with deleted reflogs' '
93
94
test_expect_success 'fails silently when using -q with not enough reflogs' '
95
ref=$(git rev-parse HEAD) &&
97
- : >.git/logs/refs/test2 &&
98
- git update-ref -m "message for refs/test2" refs/test2 "$ref" &&
96
+ git update-ref --create-reflog -m "message for refs/test2" refs/test2 "$ref" &&
97
test_must_fail git rev-parse -q --verify refs/test2@{999} >error 2>&1 &&
98
test_must_be_empty error
99
'
100
101
test_expect_success 'succeeds silently with -q and reflogs that do not go far back enough in time' '
102
ref=$(git rev-parse HEAD) &&
105
- : >.git/logs/refs/test3 &&
106
- git update-ref -m "message for refs/test3" refs/test3 "$ref" &&
103
+ git update-ref --create-reflog -m "message for refs/test3" refs/test3 "$ref" &&
104
git rev-parse -q --verify refs/test3@{1.year.ago} >actual 2>error &&
105
test_must_be_empty error &&
106
echo "$ref" >expect &&
t/t3200-branch.sh
+6
-6
@@ -59,7 +59,7 @@ test_expect_success 'git branch -l d/e/f should create a branch and a log' '
59
test_expect_success 'git branch -d d/e/f should delete a branch and a log' '
60
git branch -d d/e/f &&
61
test_path_is_missing .git/refs/heads/d/e/f &&
62
- test_path_is_missing .git/logs/refs/heads/d/e/f
62
+ test_must_fail git reflog exists refs/heads/d/e/f
63
'
64
65
test_expect_success 'git branch j/k should work after branch j has been deleted' '
@@ -82,13 +82,13 @@ test_expect_success 'git branch -m dumps usage' '
82
test_expect_success 'git branch -m m m/m should work' '
83
git branch -l m &&
84
git branch -m m m/m &&
85
- test_path_is_file .git/logs/refs/heads/m/m
85
+ git reflog exists refs/heads/m/m
86
'
87
88
test_expect_success 'git branch -m n/n n should work' '
89
git branch -l n/n &&
90
git branch -m n/n n &&
91
- test_path_is_file .git/logs/refs/heads/n
91
+ git reflog exists refs/heads/n
92
'
93
94
test_expect_success 'git branch -m o/o o should fail when o/p exists' '
@@ -267,12 +267,12 @@ git config branch.s/s.dummy Hello
267
268
test_expect_success 'git branch -m s/s s should work when s/t is deleted' '
269
git branch -l s/s &&
270
- test_path_is_file .git/logs/refs/heads/s/s &&
270
+ git reflog exists refs/heads/s/s &&
271
git branch -l s/t &&
272
- test_path_is_file .git/logs/refs/heads/s/t &&
272
+ git reflog exists refs/heads/s/t &&
273
git branch -d s/t &&
274
git branch -m s/s s &&
275
- test_path_is_file .git/logs/refs/heads/s
275
+ git reflog exists refs/heads/s
276
'
277
278
test_expect_success 'config information was renamed, too' '
t/t3210-pack-refs.sh
+1
-1
@@ -169,7 +169,7 @@ test_expect_success 'create packed foo/bar/baz branch' '
169
git branch foo/bar/baz &&
170
git pack-refs --all --prune &&
171
test_path_is_missing .git/refs/heads/foo/bar/baz &&
172
- test_path_is_missing .git/logs/refs/heads/foo/bar/baz
172
+ test_must_fail git reflog exists refs/heads/foo/bar/baz
173
'
174
175
test_expect_success 'notice d/f conflict with existing directory' '
t/t3404-rebase-interactive.sh
+5
-5
@@ -961,13 +961,13 @@ test_expect_success 'rebase -i produces readable reflog' '
961
set_fake_editor &&
962
git rebase -i --onto I F branch-reflog-test &&
963
cat >expect <<-\EOF &&
964
- rebase -i (start): checkout I
965
- rebase -i (pick): G
966
- rebase -i (pick): H
964
rebase -i (finish): returning to refs/heads/branch-reflog-test
965
+ rebase -i (pick): H
966
+ rebase -i (pick): G
967
+ rebase -i (start): checkout I
968
EOF
969
- tail -n 4 .git/logs/HEAD |
970
- sed -e "s/.* //" >actual &&
969
+ git reflog -n4 HEAD |
970
+ sed "s/[^:]*: //" >actual &&
971
test_cmp expect actual
972
'
973
t/t3903-stash.sh
+1
-1
@@ -672,7 +672,7 @@ test_expect_success 'store updates stash ref and reflog' '
672
! grep quux bazzy &&
673
git stash store -m quuxery $STASH_ID &&
674
test $(cat .git/refs/stash) = $STASH_ID &&
675
- grep $STASH_ID .git/logs/refs/stash &&
675
+ git reflog --format=%H stash| grep $STASH_ID &&
676
git stash pop &&
677
grep quux bazzy
678
'
t/t5312-prune-corruption.sh
+1
-1
@@ -12,7 +12,7 @@ delete objects that cannot be recovered.
12
13
test_expect_success 'disable reflogs' '
14
git config core.logallrefupdates false &&
15
- rm -rf .git/logs
15
+ git reflog expire --expire=all --all
16
'
17
18
test_expect_success 'create history reachable only from a bogus-named ref' '
t/t6501-freshen-objects.sh
+1
-1
@@ -56,7 +56,7 @@ for repack in '' true; do
56
57
test_expect_success "disable reflogs ($title)" '
58
git config core.logallrefupdates false &&
59
- rm -rf .git/logs
59
+ git reflog expire --expire=all --all
60
'
61
62
test_expect_success "setup basic history ($title)" '