]> git.ipfire.org Git - thirdparty/git.git/blame_incremental - t/t6439-merge-co-error-msgs.sh
The second batch
[thirdparty/git.git] / t / t6439-merge-co-error-msgs.sh
... / ...
CommitLineData
1#!/bin/sh
2
3test_description='unpack-trees error messages'
4
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8TEST_PASSES_SANITIZE_LEAK=true
9. ./test-lib.sh
10
11
12test_expect_success 'setup' '
13 echo one >one &&
14 git add one &&
15 git commit -a -m First &&
16
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 &&
24
25 git checkout main &&
26 echo other >two &&
27 echo other >three &&
28 echo other >four &&
29 echo other >five
30'
31
32cat >expect <<\EOF
33error: The following untracked working tree files would be overwritten by merge:
34 five
35 four
36 three
37 two
38Please move or remove them before you merge.
39Aborting
40EOF
41
42test_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 &&
46 (
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^
54'
55
56cat >expect <<\EOF
57error: Your local changes to the following files would be overwritten by merge:
58 four
59 three
60 two
61Please commit your changes or stash them before you merge.
62error: The following untracked working tree files would be overwritten by merge:
63 five
64Please move or remove them before you merge.
65Aborting
66EOF
67
68test_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
74'
75
76cat >expect <<\EOF
77error: Your local changes to the following files would be overwritten by checkout:
78 rep/one
79 rep/two
80Please commit your changes or stash them before you switch branches.
81Aborting
82EOF
83
84test_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
96'
97
98cat >expect <<\EOF
99error: Your local changes to the following files would be overwritten by checkout:
100 rep/one
101 rep/two
102Please commit your changes or stash them before you switch branches.
103Aborting
104EOF
105
106test_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
110'
111
112cat >expect <<\EOF
113error: Updating the following directories would lose untracked files in them:
114 rep
115 rep2
116
117Aborting
118EOF
119
120test_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
141'
142
143test_done