tests: correct "does reflog exist?" tests
These two tests weren't about how "git reflog show <branch>" exits when there is no reflog, but were about "checkout" and "branch" create or not create reflog when creating a new <branch>. Update the tests to check what we are interested in, using "git rev-parse --verify". Also lose tests based on "test -f .git/logs/refs/heads/<branch>" from nearby, to avoid exposing this particular implementation detail unnecessarily. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 21, 2010 at 12:47 UTC
6e6842e36f8c6c12ae0ddd7db98cd900b25bb8dc
2 files changed
+11
-49
t/t2017-checkout-orphan.sh
+8
-39
@@ -68,65 +68,34 @@ test_expect_success '--orphan makes reflog by default' '
68
git checkout master &&
69
git config --unset core.logAllRefUpdates &&
70
git checkout --orphan delta &&
71
- ! test -f .git/logs/refs/heads/delta &&
72
- (
73
- PAGER= &&
74
- export PAGER &&
75
- test_must_fail git reflog show delta
76
- ) &&
71
+ test_must_fail git rev-parse --verify delta@{0} &&
72
git commit -m Delta &&
78
- test -f .git/logs/refs/heads/delta &&
79
- PAGER= git reflog show delta
73
+ git rev-parse --verify delta@{0}
74
'
75
76
test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = false' '
77
git checkout master &&
78
git config core.logAllRefUpdates false &&
79
git checkout --orphan epsilon &&
86
- ! test -f .git/logs/refs/heads/epsilon &&
87
- (
88
- PAGER= &&
89
- export PAGER &&
90
- test_must_fail git reflog show epsilon
91
- ) &&
80
+ test_must_fail git rev-parse --verify epsilon@{0} &&
81
git commit -m Epsilon &&
93
- ! test -f .git/logs/refs/heads/epsilon &&
94
- (
95
- PAGER= &&
96
- export PAGER &&
97
- test_must_fail git reflog show epsilon
98
- )
82
+ test_must_fail git rev-parse --verify epsilon@{0}
83
'
84
85
test_expect_success '--orphan with -l makes reflog when core.logAllRefUpdates = false' '
86
git checkout master &&
87
git checkout -l --orphan zeta &&
104
- test -f .git/logs/refs/heads/zeta &&
105
- (
106
- PAGER= &&
107
- export PAGER &&
108
- test_must_fail git reflog show zeta
109
- ) &&
88
+ test_must_fail git rev-parse --verify zeta@{0} &&
89
git commit -m Zeta &&
111
- PAGER= git reflog show zeta
90
+ git rev-parse --verify zeta@{0}
91
'
92
93
test_expect_success 'giving up --orphan not committed when -l and core.logAllRefUpdates = false deletes reflog' '
94
git checkout master &&
95
git checkout -l --orphan eta &&
117
- test -f .git/logs/refs/heads/eta &&
118
- (
119
- PAGER= &&
120
- export PAGER &&
121
- test_must_fail git reflog show eta
122
- ) &&
96
+ test_must_fail git rev-parse --verify eta@{0} &&
97
git checkout master &&
124
- ! test -f .git/logs/refs/heads/eta &&
125
- (
126
- PAGER= &&
127
- export PAGER &&
128
- test_must_fail git reflog show eta
129
- )
98
+ test_must_fail git rev-parse --verify eta@{0}
99
'
100
101
test_expect_success '--orphan is rejected with an existing name' '
t/t3200-branch.sh
+3
-10
@@ -228,28 +228,21 @@ test_expect_success 'checkout -b makes reflog by default' '
228
git checkout master &&
229
git config --unset core.logAllRefUpdates &&
230
git checkout -b alpha &&
231
- test -f .git/logs/refs/heads/alpha &&
232
- PAGER= git reflog show alpha
231
+ git rev-parse --verify alpha@{0}
232
'
233
234
test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
235
git checkout master &&
236
git config core.logAllRefUpdates false &&
237
git checkout -b beta &&
239
- ! test -f .git/logs/refs/heads/beta &&
240
- (
241
- PAGER= &&
242
- export PAGER &&
243
- test_must_fail git reflog show beta
244
- )
238
+ test_must_fail git rev-parse --verify beta@{0}
239
'
240
241
test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
242
git checkout master &&
243
git checkout -lb gamma &&
244
git config --unset core.logAllRefUpdates &&
251
- test -f .git/logs/refs/heads/gamma &&
252
- PAGER= git reflog show gamma
245
+ git rev-parse --verify gamma@{0}
246
'
247
248
test_expect_success 'avoid ambiguous track' '