]>
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: | |
30 | two | |
31 | three | |
32 | four | |
33 | five | |
34 | Please move or remove them before you can merge. | |
35 | EOF | |
36 | ||
37 | test_expect_success 'untracked files overwritten by merge' ' | |
38 | test_must_fail git merge branch 2>out && | |
39 | test_cmp out expect | |
40 | ' | |
41 | ||
42 | cat >expect <<\EOF | |
43 | error: Your local changes to the following files would be overwritten by merge: | |
44 | two | |
45 | three | |
46 | four | |
47 | Please, commit your changes or stash them before you can merge. | |
48 | error: The following untracked working tree files would be overwritten by merge: | |
49 | five | |
50 | Please move or remove them before you can merge. | |
51 | EOF | |
52 | ||
53 | test_expect_success 'untracked files or local changes ovewritten by merge' ' | |
54 | git add two && | |
55 | git add three && | |
56 | git add four && | |
57 | test_must_fail git merge branch 2>out && | |
58 | test_cmp out expect | |
59 | ' | |
60 | ||
61 | cat >expect <<\EOF | |
62 | error: Your local changes to the following files would be overwritten by checkout: | |
63 | rep/two | |
64 | rep/one | |
65 | Please, commit your changes or stash them before you can switch branches. | |
66 | EOF | |
67 | ||
68 | test_expect_success 'cannot switch branches because of local changes' ' | |
69 | git add five && | |
70 | mkdir rep && | |
71 | echo one >rep/one && | |
72 | echo two >rep/two && | |
73 | git add rep/one rep/two && | |
74 | git commit -m Fourth && | |
75 | git checkout master && | |
76 | echo uno >rep/one && | |
77 | echo dos >rep/two && | |
78 | test_must_fail git checkout branch 2>out && | |
79 | test_cmp out expect | |
80 | ' | |
81 | ||
82 | cat >expect <<\EOF | |
83 | error: Your local changes to the following files would be overwritten by checkout: | |
84 | rep/two | |
85 | rep/one | |
86 | Please, commit your changes or stash them before you can switch branches. | |
87 | EOF | |
88 | ||
89 | test_expect_success 'not uptodate file porcelain checkout error' ' | |
90 | git add rep/one rep/two && | |
91 | test_must_fail git checkout branch 2>out && | |
92 | test_cmp out expect | |
93 | ' | |
94 | ||
95 | cat >expect <<\EOF | |
96 | error: Updating the following directories would lose untracked files in it: | |
97 | rep2 | |
98 | rep | |
99 | ||
100 | EOF | |
101 | ||
102 | test_expect_success 'not_uptodate_dir porcelain checkout error' ' | |
103 | git init uptodate && | |
104 | cd uptodate && | |
105 | mkdir rep && | |
106 | mkdir rep2 && | |
107 | touch rep/foo && | |
108 | touch rep2/foo && | |
109 | git add rep/foo rep2/foo && | |
110 | git commit -m init && | |
111 | git checkout -b branch && | |
112 | git rm rep -r && | |
113 | git rm rep2 -r && | |
114 | >rep && | |
115 | >rep2 && | |
116 | git add rep rep2&& | |
117 | git commit -m "added test as a file" && | |
118 | git checkout master && | |
119 | >rep/untracked-file && | |
120 | >rep2/untracked-file && | |
121 | test_must_fail git checkout branch 2>out && | |
122 | test_cmp out ../expect | |
123 | ' | |
124 | ||
125 | test_done |