Sync with 2.44.1
[git/gitster.git] / t / t1413-reflog-detach.sh
blobd2a4822d46fd05c45273f48b0caf48cadb2a07f1
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_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 reset_state () {
11 rm -rf .git && "$TAR" xf .git-saved.tar
14 test_expect_success setup '
15 test_tick &&
16 git commit --allow-empty -m initial &&
17 git branch side &&
18 test_tick &&
19 git commit --allow-empty -m second &&
20 "$TAR" cf .git-saved.tar .git
23 test_expect_success baseline '
24 reset_state &&
25 git rev-parse main main^ >expect &&
26 git log -g --format=%H >actual &&
27 test_cmp expect actual
30 test_expect_success 'switch to branch' '
31 reset_state &&
32 git rev-parse side main main^ >expect &&
33 git checkout side &&
34 git log -g --format=%H >actual &&
35 test_cmp expect actual
38 test_expect_success 'detach to other' '
39 reset_state &&
40 git rev-parse main side main main^ >expect &&
41 git checkout side &&
42 git checkout main^0 &&
43 git log -g --format=%H >actual &&
44 test_cmp expect actual
47 test_expect_success 'detach to self' '
48 reset_state &&
49 git rev-parse main main main^ >expect &&
50 git checkout main^0 &&
51 git log -g --format=%H >actual &&
52 test_cmp expect actual
55 test_expect_success 'attach to self' '
56 reset_state &&
57 git rev-parse main main main main^ >expect &&
58 git checkout main^0 &&
59 git checkout main &&
60 git log -g --format=%H >actual &&
61 test_cmp expect actual
64 test_expect_success 'attach to other' '
65 reset_state &&
66 git rev-parse side main main main^ >expect &&
67 git checkout main^0 &&
68 git checkout side &&
69 git log -g --format=%H >actual &&
70 test_cmp expect actual
73 test_done