]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | test_description='git reset in a bare repository' | |
4 | . ./test-lib.sh | |
5 | ||
6 | test_expect_success 'setup non-bare' ' | |
7 | echo one >file && | |
8 | git add file && | |
9 | git commit -m one && | |
10 | echo two >file && | |
11 | git commit -a -m two | |
12 | ' | |
13 | ||
14 | test_expect_success '"hard" reset requires a worktree' ' | |
15 | (cd .git && | |
16 | test_must_fail git reset --hard) | |
17 | ' | |
18 | ||
19 | test_expect_success '"merge" reset requires a worktree' ' | |
20 | (cd .git && | |
21 | test_must_fail git reset --merge) | |
22 | ' | |
23 | ||
24 | test_expect_success '"keep" reset requires a worktree' ' | |
25 | (cd .git && | |
26 | test_must_fail git reset --keep) | |
27 | ' | |
28 | ||
29 | test_expect_success '"mixed" reset is ok' ' | |
30 | (cd .git && git reset) | |
31 | ' | |
32 | ||
33 | test_expect_success '"soft" reset is ok' ' | |
34 | (cd .git && git reset --soft) | |
35 | ' | |
36 | ||
37 | test_expect_success 'hard reset works with GIT_WORK_TREE' ' | |
38 | mkdir worktree && | |
39 | GIT_WORK_TREE=$PWD/worktree GIT_DIR=$PWD/.git git reset --hard && | |
40 | test_cmp file worktree/file | |
41 | ' | |
42 | ||
43 | test_expect_success 'setup bare' ' | |
44 | git clone --bare . bare.git && | |
45 | cd bare.git | |
46 | ' | |
47 | ||
48 | test_expect_success '"hard" reset is not allowed in bare' ' | |
49 | test_must_fail git reset --hard HEAD^ | |
50 | ' | |
51 | ||
52 | test_expect_success '"merge" reset is not allowed in bare' ' | |
53 | test_must_fail git reset --merge HEAD^ | |
54 | ' | |
55 | ||
56 | test_expect_success '"keep" reset is not allowed in bare' ' | |
57 | test_must_fail git reset --keep HEAD^ | |
58 | ' | |
59 | ||
60 | test_expect_success '"mixed" reset is not allowed in bare' ' | |
61 | test_must_fail git reset --mixed HEAD^ | |
62 | ' | |
63 | ||
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" | |
67 | ' | |
68 | ||
69 | test_done |