Merge branch 'ja/doc-synopsis-markup'
[git/gitster.git] / t / t6439-merge-co-error-msgs.sh
blob0cbec57cdabc48b7cd952a6fbf5458391b44a645
1 #!/bin/sh
3 test_description='unpack-trees error messages'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
12 test_expect_success 'setup' '
13 echo one >one &&
14 git add one &&
15 git commit -a -m First &&
17 git checkout -b branch &&
18 echo two >two &&
19 echo three >three &&
20 echo four >four &&
21 echo five >five &&
22 git add two three four five &&
23 git commit -m Second &&
25 git checkout main &&
26 echo other >two &&
27 echo other >three &&
28 echo other >four &&
29 echo other >five
32 cat >expect <<\EOF
33 error: The following untracked working tree files would be overwritten by merge:
34 five
35 four
36 three
37 two
38 Please move or remove them before you merge.
39 Aborting
40 EOF
42 test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' '
43 test_must_fail git merge branch 2>out &&
44 test_cmp out expect &&
45 git commit --allow-empty -m empty &&
47 GIT_MERGE_VERBOSITY=0 &&
48 export GIT_MERGE_VERBOSITY &&
49 test_must_fail git merge branch 2>out2
50 ) &&
51 echo "Merge with strategy ${GIT_TEST_MERGE_ALGORITHM:-ort} failed." >>expect &&
52 test_cmp out2 expect &&
53 git reset --hard HEAD^
56 cat >expect <<\EOF
57 error: Your local changes to the following files would be overwritten by merge:
58 four
59 three
60 two
61 Please commit your changes or stash them before you merge.
62 error: The following untracked working tree files would be overwritten by merge:
63 five
64 Please move or remove them before you merge.
65 Aborting
66 EOF
68 test_expect_success 'untracked files or local changes ovewritten by merge' '
69 git add two &&
70 git add three &&
71 git add four &&
72 test_must_fail git merge branch 2>out &&
73 test_cmp out expect
76 cat >expect <<\EOF
77 error: Your local changes to the following files would be overwritten by checkout:
78 rep/one
79 rep/two
80 Please commit your changes or stash them before you switch branches.
81 Aborting
82 EOF
84 test_expect_success 'cannot switch branches because of local changes' '
85 git add five &&
86 mkdir rep &&
87 echo one >rep/one &&
88 echo two >rep/two &&
89 git add rep/one rep/two &&
90 git commit -m Fourth &&
91 git checkout main &&
92 echo uno >rep/one &&
93 echo dos >rep/two &&
94 test_must_fail git checkout branch 2>out &&
95 test_cmp out expect
98 cat >expect <<\EOF
99 error: Your local changes to the following files would be overwritten by checkout:
100 rep/one
101 rep/two
102 Please commit your changes or stash them before you switch branches.
103 Aborting
106 test_expect_success 'not uptodate file porcelain checkout error' '
107 git add rep/one rep/two &&
108 test_must_fail git checkout branch 2>out &&
109 test_cmp out expect
112 cat >expect <<\EOF
113 error: Updating the following directories would lose untracked files in them:
115 rep2
117 Aborting
120 test_expect_success 'not_uptodate_dir porcelain checkout error' '
121 git init uptodate &&
122 cd uptodate &&
123 mkdir rep &&
124 mkdir rep2 &&
125 touch rep/foo &&
126 touch rep2/foo &&
127 git add rep/foo rep2/foo &&
128 git commit -m init &&
129 git checkout -b branch &&
130 git rm rep -r &&
131 git rm rep2 -r &&
132 >rep &&
133 >rep2 &&
134 git add rep rep2 &&
135 git commit -m "added test as a file" &&
136 git checkout main &&
137 >rep/untracked-file &&
138 >rep2/untracked-file &&
139 test_must_fail git checkout branch 2>out &&
140 test_cmp out ../expect
143 test_done