3 test_description='Test reflog interaction with detached HEAD'
8 cp saved_reflog .git/logs/HEAD
11 test_expect_success setup '
13 git commit --allow-empty -m initial &&
16 git commit --allow-empty -m second &&
17 cat .git/logs/HEAD >saved_reflog
20 test_expect_success baseline '
22 git rev-parse master master^ >expect &&
23 git log -g --format=%H >actual &&
24 test_cmp expect actual
27 test_expect_success 'switch to branch' '
29 git rev-parse side master master^ >expect &&
31 git log -g --format=%H >actual &&
32 test_cmp expect actual
35 test_expect_success 'detach to other' '
37 git rev-parse master side master master^ >expect &&
39 git checkout master^0 &&
40 git log -g --format=%H >actual &&
41 test_cmp expect actual
44 test_expect_success 'detach to self' '
46 git rev-parse master master master^ >expect &&
47 git checkout master^0 &&
48 git log -g --format=%H >actual &&
49 test_cmp expect actual
52 test_expect_success 'attach to self' '
54 git rev-parse master master master master^ >expect &&
55 git checkout master^0 &&
56 git checkout master &&
57 git log -g --format=%H >actual &&
58 test_cmp expect actual
61 test_expect_success 'attach to other' '
63 git rev-parse side master master master^ >expect &&
64 git checkout master^0 &&
66 git log -g --format=%H >actual &&
67 test_cmp expect actual