3 test_description
='Test reflog interaction with detached HEAD'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 rm -rf .git
&& "$TAR" xf .git-saved.
tar
13 test_expect_success setup
'
15 git commit --allow-empty -m initial &&
18 git commit --allow-empty -m second &&
19 "$TAR" cf .git-saved.tar .git
22 test_expect_success baseline
'
24 git rev-parse main main^ >expect &&
25 git log -g --format=%H >actual &&
26 test_cmp expect actual
29 test_expect_success
'switch to branch' '
31 git rev-parse side main main^ >expect &&
33 git log -g --format=%H >actual &&
34 test_cmp expect actual
37 test_expect_success
'detach to other' '
39 git rev-parse main side main main^ >expect &&
41 git checkout main^0 &&
42 git log -g --format=%H >actual &&
43 test_cmp expect actual
46 test_expect_success
'detach to self' '
48 git rev-parse main main main^ >expect &&
49 git checkout main^0 &&
50 git log -g --format=%H >actual &&
51 test_cmp expect actual
54 test_expect_success
'attach to self' '
56 git rev-parse main main main main^ >expect &&
57 git checkout main^0 &&
59 git log -g --format=%H >actual &&
60 test_cmp expect actual
63 test_expect_success
'attach to other' '
65 git rev-parse side main main main^ >expect &&
66 git checkout main^0 &&
68 git log -g --format=%H >actual &&
69 test_cmp expect actual