]>
Commit | Line | Data |
---|---|---|
e935e62a DG |
1 | #!/bin/sh |
2 | ||
3 | test_description='unpack-trees error messages' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | ||
8 | test_expect_success 'setup' ' | |
9 | echo one >one && | |
10 | git add one && | |
11 | git commit -a -m First && | |
12 | ||
13 | git checkout -b branch && | |
14 | echo two >two && | |
15 | echo three >three && | |
16 | echo four >four && | |
17 | echo five >five && | |
18 | git add two three four five && | |
19 | git commit -m Second && | |
20 | ||
21 | git checkout master && | |
22 | echo other >two && | |
23 | echo other >three && | |
24 | echo other >four && | |
25 | echo other >five | |
26 | ' | |
27 | ||
28 | cat >expect <<\EOF | |
29 | error: The following untracked working tree files would be overwritten by merge: | |
e935e62a | 30 | five |
7980872d CB |
31 | four |
32 | three | |
33 | two | |
e935e62a DG |
34 | Please move or remove them before you can merge. |
35 | EOF | |
36 | ||
c5978a50 | 37 | test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' ' |
e935e62a | 38 | test_must_fail git merge branch 2>out && |
c5978a50 MM |
39 | test_cmp out expect && |
40 | git commit --allow-empty -m empty && | |
41 | ( | |
42 | GIT_MERGE_VERBOSITY=0 && | |
43 | export GIT_MERGE_VERBOSITY && | |
44 | test_must_fail git merge branch 2>out2 | |
45 | ) && | |
46 | test_cmp out2 expect && | |
47 | git reset --hard HEAD^ | |
e935e62a DG |
48 | ' |
49 | ||
50 | cat >expect <<\EOF | |
51 | error: Your local changes to the following files would be overwritten by merge: | |
e935e62a | 52 | four |
7980872d CB |
53 | three |
54 | two | |
e935e62a DG |
55 | Please, commit your changes or stash them before you can merge. |
56 | error: The following untracked working tree files would be overwritten by merge: | |
57 | five | |
58 | Please move or remove them before you can merge. | |
59 | EOF | |
60 | ||
61 | test_expect_success 'untracked files or local changes ovewritten by merge' ' | |
62 | git add two && | |
63 | git add three && | |
64 | git add four && | |
65 | test_must_fail git merge branch 2>out && | |
66 | test_cmp out expect | |
67 | ' | |
68 | ||
69 | cat >expect <<\EOF | |
70 | error: Your local changes to the following files would be overwritten by checkout: | |
e935e62a | 71 | rep/one |
7980872d | 72 | rep/two |
e935e62a DG |
73 | Please, commit your changes or stash them before you can switch branches. |
74 | EOF | |
75 | ||
76 | test_expect_success 'cannot switch branches because of local changes' ' | |
77 | git add five && | |
78 | mkdir rep && | |
79 | echo one >rep/one && | |
80 | echo two >rep/two && | |
81 | git add rep/one rep/two && | |
82 | git commit -m Fourth && | |
83 | git checkout master && | |
84 | echo uno >rep/one && | |
85 | echo dos >rep/two && | |
86 | test_must_fail git checkout branch 2>out && | |
87 | test_cmp out expect | |
88 | ' | |
89 | ||
90 | cat >expect <<\EOF | |
91 | error: Your local changes to the following files would be overwritten by checkout: | |
e935e62a | 92 | rep/one |
7980872d | 93 | rep/two |
e935e62a DG |
94 | Please, commit your changes or stash them before you can switch branches. |
95 | EOF | |
96 | ||
97 | test_expect_success 'not uptodate file porcelain checkout error' ' | |
98 | git add rep/one rep/two && | |
99 | test_must_fail git checkout branch 2>out && | |
100 | test_cmp out expect | |
101 | ' | |
102 | ||
103 | cat >expect <<\EOF | |
104 | error: Updating the following directories would lose untracked files in it: | |
e935e62a | 105 | rep |
7980872d | 106 | rep2 |
e935e62a DG |
107 | |
108 | EOF | |
109 | ||
110 | test_expect_success 'not_uptodate_dir porcelain checkout error' ' | |
111 | git init uptodate && | |
112 | cd uptodate && | |
113 | mkdir rep && | |
114 | mkdir rep2 && | |
115 | touch rep/foo && | |
116 | touch rep2/foo && | |
117 | git add rep/foo rep2/foo && | |
118 | git commit -m init && | |
119 | git checkout -b branch && | |
120 | git rm rep -r && | |
121 | git rm rep2 -r && | |
122 | >rep && | |
123 | >rep2 && | |
124 | git add rep rep2&& | |
125 | git commit -m "added test as a file" && | |
126 | git checkout master && | |
127 | >rep/untracked-file && | |
128 | >rep2/untracked-file && | |
129 | test_must_fail git checkout branch 2>out && | |
130 | test_cmp out ../expect | |
131 | ' | |
132 | ||
133 | test_done |