Sync with 2.38.4
[git.git] / t / t1413-reflog-detach.sh
blob934688a1ee82e29f2552bb2444eb06626fe254f8
1 #!/bin/sh
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
7 . ./test-lib.sh
9 reset_state () {
10 rm -rf .git && "$TAR" xf .git-saved.tar
13 test_expect_success setup '
14 test_tick &&
15 git commit --allow-empty -m initial &&
16 git branch side &&
17 test_tick &&
18 git commit --allow-empty -m second &&
19 "$TAR" cf .git-saved.tar .git
22 test_expect_success baseline '
23 reset_state &&
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' '
30 reset_state &&
31 git rev-parse side main main^ >expect &&
32 git checkout side &&
33 git log -g --format=%H >actual &&
34 test_cmp expect actual
37 test_expect_success 'detach to other' '
38 reset_state &&
39 git rev-parse main side main main^ >expect &&
40 git checkout side &&
41 git checkout main^0 &&
42 git log -g --format=%H >actual &&
43 test_cmp expect actual
46 test_expect_success 'detach to self' '
47 reset_state &&
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' '
55 reset_state &&
56 git rev-parse main main main main^ >expect &&
57 git checkout main^0 &&
58 git checkout main &&
59 git log -g --format=%H >actual &&
60 test_cmp expect actual
63 test_expect_success 'attach to other' '
64 reset_state &&
65 git rev-parse side main main main^ >expect &&
66 git checkout main^0 &&
67 git checkout side &&
68 git log -g --format=%H >actual &&
69 test_cmp expect actual
72 test_done