]>
Commit | Line | Data |
---|---|---|
014e7db3 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test reflog interaction with detached HEAD' | |
06d53148 | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
03267e86 | 7 | TEST_PASSES_SANITIZE_LEAK=true |
014e7db3 JH |
8 | . ./test-lib.sh |
9 | ||
10 | reset_state () { | |
1142746c | 11 | rm -rf .git && "$TAR" xf .git-saved.tar |
014e7db3 JH |
12 | } |
13 | ||
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 && | |
1142746c | 20 | "$TAR" cf .git-saved.tar .git |
014e7db3 JH |
21 | ' |
22 | ||
23 | test_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 | ||
30 | test_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 | ||
38 | test_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 | ||
47 | test_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 | ||
55 | test_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 | ||
64 | test_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 | ||
73 | test_done |