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 | |
c2691e2a | 34 | Please move or remove them before you merge. |
6f90969b | 35 | Aborting |
e935e62a DG |
36 | EOF |
37 | ||
c5978a50 | 38 | test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' ' |
e935e62a | 39 | test_must_fail git merge branch 2>out && |
2e3926b9 | 40 | test_i18ncmp out expect && |
c5978a50 MM |
41 | git commit --allow-empty -m empty && |
42 | ( | |
43 | GIT_MERGE_VERBOSITY=0 && | |
44 | export GIT_MERGE_VERBOSITY && | |
45 | test_must_fail git merge branch 2>out2 | |
46 | ) && | |
2e3926b9 | 47 | test_i18ncmp out2 expect && |
c5978a50 | 48 | git reset --hard HEAD^ |
e935e62a DG |
49 | ' |
50 | ||
51 | cat >expect <<\EOF | |
52 | error: Your local changes to the following files would be overwritten by merge: | |
e935e62a | 53 | four |
7980872d CB |
54 | three |
55 | two | |
c2691e2a | 56 | Please commit your changes or stash them before you merge. |
e935e62a DG |
57 | error: The following untracked working tree files would be overwritten by merge: |
58 | five | |
c2691e2a | 59 | Please move or remove them before you merge. |
6f90969b | 60 | Aborting |
e935e62a DG |
61 | EOF |
62 | ||
63 | test_expect_success 'untracked files or local changes ovewritten by merge' ' | |
64 | git add two && | |
65 | git add three && | |
66 | git add four && | |
67 | test_must_fail git merge branch 2>out && | |
2e3926b9 | 68 | test_i18ncmp out expect |
e935e62a DG |
69 | ' |
70 | ||
71 | cat >expect <<\EOF | |
72 | error: Your local changes to the following files would be overwritten by checkout: | |
e935e62a | 73 | rep/one |
7980872d | 74 | rep/two |
c2691e2a | 75 | Please commit your changes or stash them before you switch branches. |
6f90969b | 76 | Aborting |
e935e62a DG |
77 | EOF |
78 | ||
79 | test_expect_success 'cannot switch branches because of local changes' ' | |
80 | git add five && | |
81 | mkdir rep && | |
82 | echo one >rep/one && | |
83 | echo two >rep/two && | |
84 | git add rep/one rep/two && | |
85 | git commit -m Fourth && | |
86 | git checkout master && | |
87 | echo uno >rep/one && | |
88 | echo dos >rep/two && | |
89 | test_must_fail git checkout branch 2>out && | |
2e3926b9 | 90 | test_i18ncmp out expect |
e935e62a DG |
91 | ' |
92 | ||
93 | cat >expect <<\EOF | |
94 | error: Your local changes to the following files would be overwritten by checkout: | |
e935e62a | 95 | rep/one |
7980872d | 96 | rep/two |
c2691e2a | 97 | Please commit your changes or stash them before you switch branches. |
6f90969b | 98 | Aborting |
e935e62a DG |
99 | EOF |
100 | ||
101 | test_expect_success 'not uptodate file porcelain checkout error' ' | |
102 | git add rep/one rep/two && | |
103 | test_must_fail git checkout branch 2>out && | |
2e3926b9 | 104 | test_i18ncmp out expect |
e935e62a DG |
105 | ' |
106 | ||
107 | cat >expect <<\EOF | |
584f99c8 | 108 | error: Updating the following directories would lose untracked files in them: |
e935e62a | 109 | rep |
7980872d | 110 | rep2 |
e935e62a | 111 | |
6f90969b | 112 | Aborting |
e935e62a DG |
113 | EOF |
114 | ||
115 | test_expect_success 'not_uptodate_dir porcelain checkout error' ' | |
116 | git init uptodate && | |
117 | cd uptodate && | |
118 | mkdir rep && | |
119 | mkdir rep2 && | |
120 | touch rep/foo && | |
121 | touch rep2/foo && | |
122 | git add rep/foo rep2/foo && | |
123 | git commit -m init && | |
124 | git checkout -b branch && | |
125 | git rm rep -r && | |
126 | git rm rep2 -r && | |
127 | >rep && | |
128 | >rep2 && | |
129 | git add rep rep2&& | |
130 | git commit -m "added test as a file" && | |
131 | git checkout master && | |
132 | >rep/untracked-file && | |
133 | >rep2/untracked-file && | |
134 | test_must_fail git checkout branch 2>out && | |
2e3926b9 | 135 | test_i18ncmp out ../expect |
e935e62a DG |
136 | ' |
137 | ||
138 | test_done |