]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1413-reflog-detach.sh
Merge branch 'eg/config-type-path-docfix'
[thirdparty/git.git] / t / t1413-reflog-detach.sh
CommitLineData
014e7db3
JH
1#!/bin/sh
2
3test_description='Test reflog interaction with detached HEAD'
06d53148 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
03267e86 7TEST_PASSES_SANITIZE_LEAK=true
014e7db3
JH
8. ./test-lib.sh
9
10reset_state () {
1142746c 11 rm -rf .git && "$TAR" xf .git-saved.tar
014e7db3
JH
12}
13
14test_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 &&
1142746c 20 "$TAR" cf .git-saved.tar .git
014e7db3
JH
21'
22
23test_expect_success baseline '
24 reset_state &&
06d53148 25 git rev-parse main main^ >expect &&
014e7db3
JH
26 git log -g --format=%H >actual &&
27 test_cmp expect actual
28'
29
30test_expect_success 'switch to branch' '
31 reset_state &&
06d53148 32 git rev-parse side main main^ >expect &&
014e7db3
JH
33 git checkout side &&
34 git log -g --format=%H >actual &&
35 test_cmp expect actual
36'
37
38test_expect_success 'detach to other' '
39 reset_state &&
06d53148 40 git rev-parse main side main main^ >expect &&
014e7db3 41 git checkout side &&
06d53148 42 git checkout main^0 &&
014e7db3
JH
43 git log -g --format=%H >actual &&
44 test_cmp expect actual
45'
46
47test_expect_success 'detach to self' '
48 reset_state &&
06d53148
JS
49 git rev-parse main main main^ >expect &&
50 git checkout main^0 &&
014e7db3
JH
51 git log -g --format=%H >actual &&
52 test_cmp expect actual
53'
54
55test_expect_success 'attach to self' '
56 reset_state &&
06d53148
JS
57 git rev-parse main main main main^ >expect &&
58 git checkout main^0 &&
59 git checkout main &&
014e7db3
JH
60 git log -g --format=%H >actual &&
61 test_cmp expect actual
62'
63
64test_expect_success 'attach to other' '
65 reset_state &&
06d53148
JS
66 git rev-parse side main main main^ >expect &&
67 git checkout main^0 &&
014e7db3
JH
68 git checkout side &&
69 git log -g --format=%H >actual &&
70 test_cmp expect actual
71'
72
73test_done