diff options
Diffstat (limited to 't/t2020-checkout-detach.sh')
-rwxr-xr-x | t/t2020-checkout-detach.sh | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh index bc46713..8d90d02 100755 --- a/t/t2020-checkout-detach.sh +++ b/t/t2020-checkout-detach.sh @@ -4,6 +4,7 @@ test_description='checkout into detached HEAD state' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh check_detached () { @@ -16,12 +17,12 @@ check_not_detached () { PREV_HEAD_DESC='Previous HEAD position was' check_orphan_warning() { - test_i18ngrep "you are leaving $2 behind" "$1" && - test_i18ngrep ! "$PREV_HEAD_DESC" "$1" + test_grep "you are leaving $2 behind" "$1" && + test_grep ! "$PREV_HEAD_DESC" "$1" } check_no_orphan_warning() { - test_i18ngrep ! "you are leaving .* commit.*behind" "$1" && - test_i18ngrep "$PREV_HEAD_DESC" "$1" + test_grep ! "you are leaving .* commit.*behind" "$1" && + test_grep "$PREV_HEAD_DESC" "$1" } reset () { @@ -44,6 +45,18 @@ test_expect_success 'checkout branch does not detach' ' check_not_detached ' +for opt in "HEAD" "@" +do + test_expect_success "checkout $opt no-op/don't detach" ' + reset && + cat .git/HEAD >expect && + git checkout $opt && + cat .git/HEAD >actual && + check_not_detached && + test_cmp expect actual + ' +done + test_expect_success 'checkout tag detaches' ' reset && git checkout tag && @@ -163,7 +176,10 @@ test_expect_success 'tracking count is accurate after orphan check' ' git config branch.child.merge refs/heads/main && git checkout child^ && git checkout child >stdout && - test_cmp expect stdout + test_cmp expect stdout && + + git checkout --detach child >stdout && + test_grep ! "can be fast-forwarded\." stdout ' test_expect_success 'no advice given for explicit detached head state' ' |