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
12 test_expect_success
'setup' '
15 git commit -a -m First &&
17 git checkout -b branch &&
22 git add two three four five &&
23 git commit -m Second &&
33 error
: The following untracked working tree files would be overwritten by merge
:
38 Please move or remove them before you merge.
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
51 echo "Merge with strategy ${GIT_TEST_MERGE_ALGORITHM:-ort} failed." >>expect &&
52 test_cmp out2 expect &&
53 git reset --hard HEAD^
57 error
: Your
local changes to the following files would be overwritten by merge
:
61 Please commit your changes or stash them before you merge.
62 error
: The following untracked working tree files would be overwritten by merge
:
64 Please move or remove them before you merge.
68 test_expect_success
'untracked files or local changes ovewritten by merge' '
72 test_must_fail git merge branch 2>out &&
77 error
: Your
local changes to the following files would be overwritten by checkout
:
80 Please commit your changes or stash them before you switch branches.
84 test_expect_success
'cannot switch branches because of local changes' '
89 git add rep/one rep/two &&
90 git commit -m Fourth &&
94 test_must_fail git checkout branch 2>out &&
99 error
: Your
local changes to the following files would be overwritten by checkout
:
102 Please commit your changes or stash them before you switch branches.
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 &&
113 error
: Updating the following directories would lose untracked files
in them
:
120 test_expect_success
'not_uptodate_dir porcelain checkout error' '
127 git add rep/foo rep2/foo &&
128 git commit -m init &&
129 git checkout -b branch &&
135 git commit -m "added test as a file" &&
137 >rep/untracked-file &&
138 >rep2/untracked-file &&
139 test_must_fail git checkout branch 2>out &&
140 test_cmp out ../expect