Start the 2.46 cycle
[git.git] / t / t7103-reset-bare.sh
blob18bbd9975ebfda330d0727c600bd0cec4b8b5181
1 #!/bin/sh
3 test_description='git reset in a bare repository'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup non-bare' '
9 echo one >file &&
10 git add file &&
11 git commit -m one &&
12 echo two >file &&
13 git commit -a -m two
16 test_expect_success '"hard" reset requires a worktree' '
17 (cd .git &&
18 test_must_fail git reset --hard)
21 test_expect_success '"merge" reset requires a worktree' '
22 (cd .git &&
23 test_must_fail git reset --merge)
26 test_expect_success '"keep" reset requires a worktree' '
27 (cd .git &&
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' '
40 mkdir worktree &&
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 &&
47 cd 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 &&
69 echo one >expect &&
70 head -n 1 out >actual &&
71 test_cmp expect actual
74 test_done