@@ -49,6 +49,62 @@ test_expect_success '--orphan must be rejected with -b' '
4949 test refs/heads/master = "$(git symbolic-ref HEAD)"
5050'
5151
52+ test_expect_success ' --orphan must be rejected with -t' '
53+ git checkout master &&
54+ test_must_fail git checkout --orphan new -t master &&
55+ test refs/heads/master = "$(git symbolic-ref HEAD)"
56+ '
57+
58+ test_expect_success ' --orphan ignores branch.autosetupmerge' '
59+ git checkout master &&
60+ git config branch.autosetupmerge always &&
61+ git checkout --orphan gamma &&
62+ test -z "$(git config branch.gamma.merge)" &&
63+ test refs/heads/gamma = "$(git symbolic-ref HEAD)" &&
64+ test_must_fail git rev-parse --verify HEAD^
65+ '
66+
67+ test_expect_success ' --orphan makes reflog by default' '
68+ git checkout master &&
69+ git config --unset core.logAllRefUpdates &&
70+ git checkout --orphan delta &&
71+ ! test -f .git/logs/refs/heads/delta &&
72+ test_must_fail PAGER= git reflog show delta &&
73+ git commit -m Delta &&
74+ test -f .git/logs/refs/heads/delta &&
75+ PAGER= git reflog show delta
76+ '
77+
78+ test_expect_success ' --orphan does not make reflog when core.logAllRefUpdates = false' '
79+ git checkout master &&
80+ git config core.logAllRefUpdates false &&
81+ git checkout --orphan epsilon &&
82+ ! test -f .git/logs/refs/heads/epsilon &&
83+ test_must_fail PAGER= git reflog show epsilon &&
84+ git commit -m Epsilon &&
85+ ! test -f .git/logs/refs/heads/epsilon &&
86+ test_must_fail PAGER= git reflog show epsilon
87+ '
88+
89+ test_expect_success ' --orphan with -l makes reflog when core.logAllRefUpdates = false' '
90+ git checkout master &&
91+ git checkout -l --orphan zeta &&
92+ test -f .git/logs/refs/heads/zeta &&
93+ test_must_fail PAGER= git reflog show zeta &&
94+ git commit -m Zeta &&
95+ PAGER= git reflog show zeta
96+ '
97+
98+ test_expect_success ' giving up --orphan not committed when -l and core.logAllRefUpdates = false deletes reflog' '
99+ git checkout master &&
100+ git checkout -l --orphan eta &&
101+ test -f .git/logs/refs/heads/eta &&
102+ test_must_fail PAGER= git reflog show eta &&
103+ git checkout master &&
104+ ! test -f .git/logs/refs/heads/eta &&
105+ test_must_fail PAGER= git reflog show eta
106+ '
107+
52108test_expect_success ' --orphan is rejected with an existing name' '
53109 git checkout master &&
54110 test_must_fail git checkout --orphan master &&
@@ -60,31 +116,11 @@ test_expect_success '--orphan refuses to switch if a merge is needed' '
60116 git reset --hard &&
61117 echo local >>"$TEST_FILE" &&
62118 cat "$TEST_FILE" >"$TEST_FILE.saved" &&
63- test_must_fail git checkout --orphan gamma master^ &&
119+ test_must_fail git checkout --orphan new master^ &&
64120 test refs/heads/master = "$(git symbolic-ref HEAD)" &&
65121 test_cmp "$TEST_FILE" "$TEST_FILE.saved" &&
66122 git diff-index --quiet --cached HEAD &&
67123 git reset --hard
68124'
69125
70- test_expect_success ' --orphan does not mix well with -t' '
71- git checkout master &&
72- test_must_fail git checkout -t master --orphan gamma &&
73- test refs/heads/master = "$(git symbolic-ref HEAD)"
74- '
75-
76- test_expect_success ' --orphan ignores branch.autosetupmerge' '
77- git checkout -f master &&
78- git config branch.autosetupmerge always &&
79- git checkout --orphan delta &&
80- test -z "$(git config branch.delta.merge)" &&
81- test refs/heads/delta = "$(git symbolic-ref HEAD)" &&
82- test_must_fail git rev-parse --verify HEAD^
83- '
84-
85- test_expect_success ' --orphan does not mix well with -l' '
86- git checkout -f master &&
87- test_must_fail git checkout -l --orphan gamma
88- '
89-
90126test_done
0 commit comments