3 test_description
='git reset in a bare repository'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup non-bare' '
16 test_expect_success
'"hard" reset requires a worktree' '
18 test_must_fail git reset --hard)
21 test_expect_success
'"merge" reset requires a worktree' '
23 test_must_fail git reset --merge)
26 test_expect_success
'"keep" reset requires a worktree' '
28 test_must_fail git reset --keep)
31 test_expect_success
'"mixed" reset is ok' '
32 (cd .git && git reset)
35 test_expect_success
'"soft" reset is ok' '
36 (cd .git && git reset --soft)
39 test_expect_success
'hard reset works with GIT_WORK_TREE' '
41 GIT_WORK_TREE=$PWD/worktree GIT_DIR=$PWD/.git git reset --hard &&
42 test_cmp file worktree/file
45 test_expect_success
'setup bare' '
46 git clone --bare . bare.git &&
50 test_expect_success
'"hard" reset is not allowed in bare' '
51 test_must_fail git reset --hard HEAD^
54 test_expect_success
'"merge" reset is not allowed in bare' '
55 test_must_fail git reset --merge HEAD^
58 test_expect_success
'"keep" reset is not allowed in bare' '
59 test_must_fail git reset --keep HEAD^
62 test_expect_success
'"mixed" reset is not allowed in bare' '
63 test_must_fail git reset --mixed HEAD^
66 test_expect_success
'"soft" reset is allowed in bare' '
67 git reset --soft HEAD^ &&
68 git show --pretty=format:%s >out &&
70 head -n 1 out >actual &&
71 test_cmp expect actual