Skip to content

Commit 6e6842e

Browse files
committed
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 <[email protected]>
1 parent b1edaf6 commit 6e6842e

File tree

2 files changed

+11
-49
lines changed

2 files changed

+11
-49
lines changed

t/t2017-checkout-orphan.sh

+8-39
Original file line numberDiff line numberDiff line change
@@ -68,65 +68,34 @@ test_expect_success '--orphan makes reflog by default' '
6868
git checkout master &&
6969
git config --unset core.logAllRefUpdates &&
7070
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} &&
7772
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}
8074
'
8175

8276
test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = false' '
8377
git checkout master &&
8478
git config core.logAllRefUpdates false &&
8579
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} &&
9281
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}
9983
'
10084

10185
test_expect_success '--orphan with -l makes reflog when core.logAllRefUpdates = false' '
10286
git checkout master &&
10387
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} &&
11089
git commit -m Zeta &&
111-
PAGER= git reflog show zeta
90+
git rev-parse --verify zeta@{0}
11291
'
11392

11493
test_expect_success 'giving up --orphan not committed when -l and core.logAllRefUpdates = false deletes reflog' '
11594
git checkout master &&
11695
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} &&
12397
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}
13099
'
131100

132101
test_expect_success '--orphan is rejected with an existing name' '

t/t3200-branch.sh

+3-10
Original file line numberDiff line numberDiff line change
@@ -228,28 +228,21 @@ test_expect_success 'checkout -b makes reflog by default' '
228228
git checkout master &&
229229
git config --unset core.logAllRefUpdates &&
230230
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}
233232
'
234233

235234
test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
236235
git checkout master &&
237236
git config core.logAllRefUpdates false &&
238237
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}
245239
'
246240

247241
test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
248242
git checkout master &&
249243
git checkout -lb gamma &&
250244
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}
253246
'
254247

255248
test_expect_success 'avoid ambiguous track' '

0 commit comments

Comments
 (0)