I hope I am not giving you undue burden, but here is what I would add. One thing that I am not sure about is what to do with "-l --orhpan". --- t/t2017-checkout-orphan.sh | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 42 insertions(+), 1 deletions(-) diff --git a/t/t2017-checkout-orphan.sh b/t/t2017-checkout-orphan.sh index 5a9a3fa..e80e167 100755 --- a/t/t2017-checkout-orphan.sh +++ b/t/t2017-checkout-orphan.sh @@ -44,7 +44,48 @@ test_expect_success '--orphan creates a new orphan branch from <start_point>' ' ' test_expect_success '--orphan must be rejected with -b' ' - test_must_fail git checkout --orphan new -b newer + git checkout master && + test_must_fail git checkout --orphan new -b newer && + test refs/heads/master = "$(git symbolic-ref HEAD)" +' + +test_expect_success '--orphan is rejected with an existing name' ' + git checkout master && + test_must_fail git checkout --orphan master && + test refs/heads/master = "$(git symbolic-ref HEAD)" +' + +test_expect_success '--orhapn refuses to switch if a merge is needed' ' + git checkout master && + git reset --hard && + echo local >>"$TEST_FILE" && + cat "$TEST_FILE" >"$TEST_FILE.saved" && + test_must_fail git checkout --orphan gamma master^ && + test refs/heads/master = "$(git symbolic-ref HEAD)" && + test_cmp "$TEST_FILE" "$TEST_FILE.saved" && + git diff-index --quiet --cached HEAD && + git reset --hard +' + +test_expect_success '--orphan does not mix well with -t' ' + git checkout master && + test_must_fail git checkout -t master --orphan gamma && + test refs/heads/master = "$(git symbolic-ref HEAD)" +' + +test_expect_success '--orphan ignores branch.autosetupmerge' ' + git checkout -f master && + git config branch.autosetupmerge always && + git checkout --orphan delta && + test -z "$(git config branch.delta.merge)" && + test refs/heads/delta = "$(git symbolic-ref HEAD)" && + test_must_fail git rev-parse --verify HEAD^ +' + +# This is iffy. +test_expect_success '--orphan does not mix well with -l' ' + git checkout -f master && + test_must_fail git checkout -l --orphan gamma ' test_done -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html