Merge branch 'ks/blame-worktree-textconv-cached' into maint
[git/mingw/4msysgit.git] / t / t7609-merge-co-error-msgs.sh
blobc994836c53224dd0a8302f7a6ab63b35f8b493e3
1 #!/bin/sh
3 test_description='unpack-trees error messages'
5 . ./test-lib.sh
8 test_expect_success 'setup' '
9 echo one >one &&
10 git add one &&
11 git commit -a -m First &&
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 &&
21 git checkout master &&
22 echo other >two &&
23 echo other >three &&
24 echo other >four &&
25 echo other >five
28 cat >expect <<\EOF
29 error: The following untracked working tree files would be overwritten by merge:
30 five
31 four
32 three
33 two
34 Please move or remove them before you can merge.
35 EOF
37 test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' '
38 test_must_fail git merge branch 2>out &&
39 test_cmp out expect &&
40 git commit --allow-empty -m empty &&
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^
50 cat >expect <<\EOF
51 error: Your local changes to the following files would be overwritten by merge:
52 four
53 three
54 two
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
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
69 cat >expect <<\EOF
70 error: Your local changes to the following files would be overwritten by checkout:
71 rep/one
72 rep/two
73 Please, commit your changes or stash them before you can switch branches.
74 EOF
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
90 cat >expect <<\EOF
91 error: Your local changes to the following files would be overwritten by checkout:
92 rep/one
93 rep/two
94 Please, commit your changes or stash them before you can switch branches.
95 EOF
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
103 cat >expect <<\EOF
104 error: Updating the following directories would lose untracked files in it:
106 rep2
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
133 test_done