3 test_description
='unpack-trees error messages'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 test_expect_success
'setup' '
14 git commit -a -m First &&
16 git checkout -b branch &&
21 git add two three four five &&
22 git commit -m Second &&
32 error
: The following untracked working tree files would be overwritten by merge
:
37 Please move or remove them before you merge.
41 test_expect_success
'untracked files overwritten by merge (fast and non-fast forward)' '
42 test_must_fail git merge branch 2>out &&
43 test_cmp out expect &&
44 git commit --allow-empty -m empty &&
46 GIT_MERGE_VERBOSITY=0 &&
47 export GIT_MERGE_VERBOSITY &&
48 test_must_fail git merge branch 2>out2
50 echo "Merge with strategy ${GIT_TEST_MERGE_ALGORITHM:-ort} failed." >>expect &&
51 test_cmp out2 expect &&
52 git reset --hard HEAD^
56 error
: Your
local changes to the following files would be overwritten by merge
:
60 Please commit your changes or stash them before you merge.
61 error
: The following untracked working tree files would be overwritten by merge
:
63 Please move or remove them before you merge.
67 test_expect_success
'untracked files or local changes ovewritten by merge' '
71 test_must_fail git merge branch 2>out &&
76 error
: Your
local changes to the following files would be overwritten by checkout
:
79 Please commit your changes or stash them before you switch branches.
83 test_expect_success
'cannot switch branches because of local changes' '
88 git add rep/one rep/two &&
89 git commit -m Fourth &&
93 test_must_fail git checkout branch 2>out &&
98 error
: Your
local changes to the following files would be overwritten by checkout
:
101 Please commit your changes or stash them before you switch branches.
105 test_expect_success
'not uptodate file porcelain checkout error' '
106 git add rep/one rep/two &&
107 test_must_fail git checkout branch 2>out &&
112 error
: Updating the following directories would lose untracked files
in them
:
119 test_expect_success
'not_uptodate_dir porcelain checkout error' '
126 git add rep/foo rep2/foo &&
127 git commit -m init &&
128 git checkout -b branch &&
134 git commit -m "added test as a file" &&
136 >rep/untracked-file &&
137 >rep2/untracked-file &&
138 test_must_fail git checkout branch 2>out &&
139 test_cmp out ../expect