]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7103-reset-bare.sh
The third batch
[thirdparty/git.git] / t / t7103-reset-bare.sh
1 #!/bin/sh
2
3 test_description='git reset in a bare repository'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
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
14 '
15
16 test_expect_success '"hard" reset requires a worktree' '
17 (cd .git &&
18 test_must_fail git reset --hard)
19 '
20
21 test_expect_success '"merge" reset requires a worktree' '
22 (cd .git &&
23 test_must_fail git reset --merge)
24 '
25
26 test_expect_success '"keep" reset requires a worktree' '
27 (cd .git &&
28 test_must_fail git reset --keep)
29 '
30
31 test_expect_success '"mixed" reset is ok' '
32 (cd .git && git reset)
33 '
34
35 test_expect_success '"soft" reset is ok' '
36 (cd .git && git reset --soft)
37 '
38
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
43 '
44
45 test_expect_success 'setup bare' '
46 git clone --bare . bare.git &&
47 cd bare.git
48 '
49
50 test_expect_success '"hard" reset is not allowed in bare' '
51 test_must_fail git reset --hard HEAD^
52 '
53
54 test_expect_success '"merge" reset is not allowed in bare' '
55 test_must_fail git reset --merge HEAD^
56 '
57
58 test_expect_success '"keep" reset is not allowed in bare' '
59 test_must_fail git reset --keep HEAD^
60 '
61
62 test_expect_success '"mixed" reset is not allowed in bare' '
63 test_must_fail git reset --mixed HEAD^
64 '
65
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
72 '
73
74 test_done