3 test_description='unpack-trees error messages'
8 test_expect_success 'setup' '
11 git commit -a -m First &&
13 git checkout -b branch &&
18 git add two three four five &&
19 git commit -m Second &&
21 git checkout master &&
29 error: The following untracked working tree files would be overwritten by merge:
34 Please move or remove them before you can merge.
38 test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' '
39 test_must_fail git merge branch 2>out &&
40 test_cmp out expect &&
41 git commit --allow-empty -m empty &&
43 GIT_MERGE_VERBOSITY=0 &&
44 export GIT_MERGE_VERBOSITY &&
45 test_must_fail git merge branch 2>out2
47 test_cmp out2 expect &&
48 git reset --hard HEAD^
52 error: Your local changes to the following files would be overwritten by merge:
56 Please, commit your changes or stash them before you can merge.
57 error: The following untracked working tree files would be overwritten by merge:
59 Please move or remove them before you can merge.
63 test_expect_success 'untracked files or local changes ovewritten by merge' '
67 test_must_fail git merge branch 2>out &&
72 error: Your local changes to the following files would be overwritten by checkout:
75 Please, commit your changes or stash them before you can switch branches.
79 test_expect_success 'cannot switch branches because of local changes' '
84 git add rep/one rep/two &&
85 git commit -m Fourth &&
86 git checkout master &&
89 test_must_fail git checkout branch 2>out &&
94 error: Your local changes to the following files would be overwritten by checkout:
97 Please, commit your changes or stash them before you can switch branches.
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 &&
108 error: Updating the following directories would lose untracked files in it:
115 test_expect_success 'not_uptodate_dir porcelain checkout error' '
122 git add rep/foo rep2/foo &&
123 git commit -m init &&
124 git checkout -b branch &&
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 &&
135 test_cmp out ../expect