]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6439-merge-co-error-msgs.sh
t6[4-9]*: adjust the references to the default branch name "main"
[thirdparty/git.git] / t / t6439-merge-co-error-msgs.sh
CommitLineData
e935e62a
DG
1#!/bin/sh
2
3test_description='unpack-trees error messages'
4
5902f5f4 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
e935e62a
DG
8. ./test-lib.sh
9
10
11test_expect_success 'setup' '
12 echo one >one &&
13 git add one &&
14 git commit -a -m First &&
15
16 git checkout -b branch &&
17 echo two >two &&
18 echo three >three &&
19 echo four >four &&
20 echo five >five &&
21 git add two three four five &&
22 git commit -m Second &&
23
5902f5f4 24 git checkout main &&
e935e62a
DG
25 echo other >two &&
26 echo other >three &&
27 echo other >four &&
28 echo other >five
29'
30
31cat >expect <<\EOF
32error: The following untracked working tree files would be overwritten by merge:
e935e62a 33 five
7980872d
CB
34 four
35 three
36 two
c2691e2a 37Please move or remove them before you merge.
6f90969b 38Aborting
e935e62a
DG
39EOF
40
c5978a50 41test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' '
e935e62a 42 test_must_fail git merge branch 2>out &&
2e3926b9 43 test_i18ncmp out expect &&
c5978a50
MM
44 git commit --allow-empty -m empty &&
45 (
46 GIT_MERGE_VERBOSITY=0 &&
47 export GIT_MERGE_VERBOSITY &&
48 test_must_fail git merge branch 2>out2
49 ) &&
2e3926b9 50 test_i18ncmp out2 expect &&
c5978a50 51 git reset --hard HEAD^
e935e62a
DG
52'
53
54cat >expect <<\EOF
55error: Your local changes to the following files would be overwritten by merge:
e935e62a 56 four
7980872d
CB
57 three
58 two
c2691e2a 59Please commit your changes or stash them before you merge.
e935e62a
DG
60error: The following untracked working tree files would be overwritten by merge:
61 five
c2691e2a 62Please move or remove them before you merge.
6f90969b 63Aborting
e935e62a
DG
64EOF
65
66test_expect_success 'untracked files or local changes ovewritten by merge' '
67 git add two &&
68 git add three &&
69 git add four &&
70 test_must_fail git merge branch 2>out &&
2e3926b9 71 test_i18ncmp out expect
e935e62a
DG
72'
73
74cat >expect <<\EOF
75error: Your local changes to the following files would be overwritten by checkout:
e935e62a 76 rep/one
7980872d 77 rep/two
c2691e2a 78Please commit your changes or stash them before you switch branches.
6f90969b 79Aborting
e935e62a
DG
80EOF
81
82test_expect_success 'cannot switch branches because of local changes' '
83 git add five &&
84 mkdir rep &&
85 echo one >rep/one &&
86 echo two >rep/two &&
87 git add rep/one rep/two &&
88 git commit -m Fourth &&
5902f5f4 89 git checkout main &&
e935e62a
DG
90 echo uno >rep/one &&
91 echo dos >rep/two &&
92 test_must_fail git checkout branch 2>out &&
2e3926b9 93 test_i18ncmp out expect
e935e62a
DG
94'
95
96cat >expect <<\EOF
97error: Your local changes to the following files would be overwritten by checkout:
e935e62a 98 rep/one
7980872d 99 rep/two
c2691e2a 100Please commit your changes or stash them before you switch branches.
6f90969b 101Aborting
e935e62a
DG
102EOF
103
104test_expect_success 'not uptodate file porcelain checkout error' '
105 git add rep/one rep/two &&
106 test_must_fail git checkout branch 2>out &&
2e3926b9 107 test_i18ncmp out expect
e935e62a
DG
108'
109
110cat >expect <<\EOF
584f99c8 111error: Updating the following directories would lose untracked files in them:
e935e62a 112 rep
7980872d 113 rep2
e935e62a 114
6f90969b 115Aborting
e935e62a
DG
116EOF
117
118test_expect_success 'not_uptodate_dir porcelain checkout error' '
119 git init uptodate &&
120 cd uptodate &&
121 mkdir rep &&
122 mkdir rep2 &&
123 touch rep/foo &&
124 touch rep2/foo &&
125 git add rep/foo rep2/foo &&
126 git commit -m init &&
127 git checkout -b branch &&
128 git rm rep -r &&
129 git rm rep2 -r &&
130 >rep &&
131 >rep2 &&
64d1022e 132 git add rep rep2 &&
e935e62a 133 git commit -m "added test as a file" &&
5902f5f4 134 git checkout main &&
e935e62a
DG
135 >rep/untracked-file &&
136 >rep2/untracked-file &&
137 test_must_fail git checkout branch 2>out &&
2e3926b9 138 test_i18ncmp out ../expect
e935e62a
DG
139'
140
141test_done