3 test_description
='git reset in a bare repository'
6 test_expect_success
'setup non-bare' '
14 test_expect_success
'"hard" reset requires a worktree' '
16 test_must_fail git reset --hard)
19 test_expect_success
'"merge" reset requires a worktree' '
21 test_must_fail git reset --merge)
24 test_expect_success
'"keep" reset requires a worktree' '
26 test_must_fail git reset --keep)
29 test_expect_success
'"mixed" reset is ok' '
30 (cd .git && git reset)
33 test_expect_success
'"soft" reset is ok' '
34 (cd .git && git reset --soft)
37 test_expect_success
'hard reset works with GIT_WORK_TREE' '
39 GIT_WORK_TREE=$PWD/worktree GIT_DIR=$PWD/.git git reset --hard &&
40 test_cmp file worktree/file
43 test_expect_success
'setup bare' '
44 git clone --bare . bare.git &&
48 test_expect_success
'"hard" reset is not allowed in bare' '
49 test_must_fail git reset --hard HEAD^
52 test_expect_success
'"merge" reset is not allowed in bare' '
53 test_must_fail git reset --merge HEAD^
56 test_expect_success
'"keep" reset is not allowed in bare' '
57 test_must_fail git reset --keep HEAD^
60 test_expect_success
'"mixed" reset is not allowed in bare' '
61 test_must_fail git reset --mixed HEAD^
64 test_expect_success
'"soft" reset is allowed in bare' '
65 git reset --soft HEAD^ &&
66 test "`git show --pretty=format:%s | head -n 1`" = "one"