2010-08-11 08:38:08 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='unpack-trees error messages'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
echo one >one &&
|
|
|
|
git add one &&
|
|
|
|
git commit -a -m First &&
|
|
|
|
|
|
|
|
git checkout -b branch &&
|
|
|
|
echo two >two &&
|
|
|
|
echo three >three &&
|
|
|
|
echo four >four &&
|
|
|
|
echo five >five &&
|
|
|
|
git add two three four five &&
|
|
|
|
git commit -m Second &&
|
|
|
|
|
|
|
|
git checkout master &&
|
|
|
|
echo other >two &&
|
|
|
|
echo other >three &&
|
|
|
|
echo other >four &&
|
|
|
|
echo other >five
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<\EOF
|
|
|
|
error: The following untracked working tree files would be overwritten by merge:
|
|
|
|
five
|
2010-11-15 19:52:19 +00:00
|
|
|
four
|
|
|
|
three
|
|
|
|
two
|
2016-06-25 06:34:04 +00:00
|
|
|
Please move or remove them before you merge.
|
2011-09-21 07:48:36 +00:00
|
|
|
Aborting
|
2010-08-11 08:38:08 +00:00
|
|
|
EOF
|
|
|
|
|
2010-09-03 15:25:33 +00:00
|
|
|
test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' '
|
2010-08-11 08:38:08 +00:00
|
|
|
test_must_fail git merge branch 2>out &&
|
2016-05-12 23:16:26 +00:00
|
|
|
test_i18ncmp out expect &&
|
2010-09-03 15:25:33 +00:00
|
|
|
git commit --allow-empty -m empty &&
|
|
|
|
(
|
|
|
|
GIT_MERGE_VERBOSITY=0 &&
|
|
|
|
export GIT_MERGE_VERBOSITY &&
|
|
|
|
test_must_fail git merge branch 2>out2
|
|
|
|
) &&
|
2016-05-12 23:16:26 +00:00
|
|
|
test_i18ncmp out2 expect &&
|
2010-09-03 15:25:33 +00:00
|
|
|
git reset --hard HEAD^
|
2010-08-11 08:38:08 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<\EOF
|
|
|
|
error: Your local changes to the following files would be overwritten by merge:
|
|
|
|
four
|
2010-11-15 19:52:19 +00:00
|
|
|
three
|
|
|
|
two
|
2016-06-25 06:34:04 +00:00
|
|
|
Please commit your changes or stash them before you merge.
|
2010-08-11 08:38:08 +00:00
|
|
|
error: The following untracked working tree files would be overwritten by merge:
|
|
|
|
five
|
2016-06-25 06:34:04 +00:00
|
|
|
Please move or remove them before you merge.
|
2011-09-21 07:48:36 +00:00
|
|
|
Aborting
|
2010-08-11 08:38:08 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'untracked files or local changes ovewritten by merge' '
|
|
|
|
git add two &&
|
|
|
|
git add three &&
|
|
|
|
git add four &&
|
|
|
|
test_must_fail git merge branch 2>out &&
|
2016-05-12 23:16:26 +00:00
|
|
|
test_i18ncmp out expect
|
2010-08-11 08:38:08 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<\EOF
|
|
|
|
error: Your local changes to the following files would be overwritten by checkout:
|
|
|
|
rep/one
|
2010-11-15 19:52:19 +00:00
|
|
|
rep/two
|
2016-06-25 06:34:04 +00:00
|
|
|
Please commit your changes or stash them before you switch branches.
|
2011-09-21 07:48:36 +00:00
|
|
|
Aborting
|
2010-08-11 08:38:08 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'cannot switch branches because of local changes' '
|
|
|
|
git add five &&
|
|
|
|
mkdir rep &&
|
|
|
|
echo one >rep/one &&
|
|
|
|
echo two >rep/two &&
|
|
|
|
git add rep/one rep/two &&
|
|
|
|
git commit -m Fourth &&
|
|
|
|
git checkout master &&
|
|
|
|
echo uno >rep/one &&
|
|
|
|
echo dos >rep/two &&
|
|
|
|
test_must_fail git checkout branch 2>out &&
|
2016-05-12 23:16:26 +00:00
|
|
|
test_i18ncmp out expect
|
2010-08-11 08:38:08 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<\EOF
|
|
|
|
error: Your local changes to the following files would be overwritten by checkout:
|
|
|
|
rep/one
|
2010-11-15 19:52:19 +00:00
|
|
|
rep/two
|
2016-06-25 06:34:04 +00:00
|
|
|
Please commit your changes or stash them before you switch branches.
|
2011-09-21 07:48:36 +00:00
|
|
|
Aborting
|
2010-08-11 08:38:08 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'not uptodate file porcelain checkout error' '
|
|
|
|
git add rep/one rep/two &&
|
|
|
|
test_must_fail git checkout branch 2>out &&
|
2016-05-12 23:16:26 +00:00
|
|
|
test_i18ncmp out expect
|
2010-08-11 08:38:08 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<\EOF
|
2016-12-02 19:17:41 +00:00
|
|
|
error: Updating the following directories would lose untracked files in them:
|
2010-08-11 08:38:08 +00:00
|
|
|
rep
|
2010-11-15 19:52:19 +00:00
|
|
|
rep2
|
2010-08-11 08:38:08 +00:00
|
|
|
|
2011-09-21 07:48:36 +00:00
|
|
|
Aborting
|
2010-08-11 08:38:08 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'not_uptodate_dir porcelain checkout error' '
|
|
|
|
git init uptodate &&
|
|
|
|
cd uptodate &&
|
|
|
|
mkdir rep &&
|
|
|
|
mkdir rep2 &&
|
|
|
|
touch rep/foo &&
|
|
|
|
touch rep2/foo &&
|
|
|
|
git add rep/foo rep2/foo &&
|
|
|
|
git commit -m init &&
|
|
|
|
git checkout -b branch &&
|
|
|
|
git rm rep -r &&
|
|
|
|
git rm rep2 -r &&
|
|
|
|
>rep &&
|
|
|
|
>rep2 &&
|
|
|
|
git add rep rep2&&
|
|
|
|
git commit -m "added test as a file" &&
|
|
|
|
git checkout master &&
|
|
|
|
>rep/untracked-file &&
|
|
|
|
>rep2/untracked-file &&
|
|
|
|
test_must_fail git checkout branch 2>out &&
|
2016-05-12 23:16:26 +00:00
|
|
|
test_i18ncmp out ../expect
|
2010-08-11 08:38:08 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|