]>
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 | ||
014e7db3 JH |
7 | . ./test-lib.sh |
8 | ||
9 | reset_state () { | |
1142746c | 10 | rm -rf .git && "$TAR" xf .git-saved.tar |
014e7db3 JH |
11 | } |
12 | ||
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 && | |
1142746c | 19 | "$TAR" cf .git-saved.tar .git |
014e7db3 JH |
20 | ' |
21 | ||
22 | test_expect_success baseline ' | |
23 | reset_state && | |
06d53148 | 24 | git rev-parse main main^ >expect && |
014e7db3 JH |
25 | git log -g --format=%H >actual && |
26 | test_cmp expect actual | |
27 | ' | |
28 | ||
29 | test_expect_success 'switch to branch' ' | |
30 | reset_state && | |
06d53148 | 31 | git rev-parse side main main^ >expect && |
014e7db3 JH |
32 | git checkout side && |
33 | git log -g --format=%H >actual && | |
34 | test_cmp expect actual | |
35 | ' | |
36 | ||
37 | test_expect_success 'detach to other' ' | |
38 | reset_state && | |
06d53148 | 39 | git rev-parse main side main main^ >expect && |
014e7db3 | 40 | git checkout side && |
06d53148 | 41 | git checkout main^0 && |
014e7db3 JH |
42 | git log -g --format=%H >actual && |
43 | test_cmp expect actual | |
44 | ' | |
45 | ||
46 | test_expect_success 'detach to self' ' | |
47 | reset_state && | |
06d53148 JS |
48 | git rev-parse main main main^ >expect && |
49 | git checkout main^0 && | |
014e7db3 JH |
50 | git log -g --format=%H >actual && |
51 | test_cmp expect actual | |
52 | ' | |
53 | ||
54 | test_expect_success 'attach to self' ' | |
55 | reset_state && | |
06d53148 JS |
56 | git rev-parse main main main main^ >expect && |
57 | git checkout main^0 && | |
58 | git checkout main && | |
014e7db3 JH |
59 | git log -g --format=%H >actual && |
60 | test_cmp expect actual | |
61 | ' | |
62 | ||
63 | test_expect_success 'attach to other' ' | |
64 | reset_state && | |
06d53148 JS |
65 | git rev-parse side main main main^ >expect && |
66 | git checkout main^0 && | |
014e7db3 JH |
67 | git checkout side && |
68 | git log -g --format=%H >actual && | |
69 | test_cmp expect actual | |
70 | ' | |
71 | ||
72 | test_done |