Git fork
at reftables-rust 142 lines 3.2 kB view raw
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 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 24 git checkout main && 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: 33 five 34 four 35 three 36 two 37Please move or remove them before you merge. 38Aborting 39EOF 40 41test_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 && 45 ( 46 GIT_MERGE_VERBOSITY=0 && 47 export GIT_MERGE_VERBOSITY && 48 test_must_fail git merge branch 2>out2 49 ) && 50 echo "Merge with strategy ort failed." >>expect && 51 test_cmp out2 expect && 52 git reset --hard HEAD^ 53' 54 55cat >expect <<\EOF 56error: Your local changes to the following files would be overwritten by merge: 57 four 58 three 59 two 60Please commit your changes or stash them before you merge. 61error: The following untracked working tree files would be overwritten by merge: 62 five 63Please move or remove them before you merge. 64Aborting 65EOF 66 67test_expect_success 'untracked files or local changes overwritten by merge' ' 68 git add two && 69 git add three && 70 git add four && 71 test_must_fail git merge branch 2>out && 72 test_cmp out expect 73' 74 75cat >expect <<\EOF 76error: Your local changes to the following files would be overwritten by checkout: 77 rep/one 78 rep/two 79Please commit your changes or stash them before you switch branches. 80Aborting 81EOF 82 83test_expect_success 'cannot switch branches because of local changes' ' 84 git add five && 85 mkdir rep && 86 echo one >rep/one && 87 echo two >rep/two && 88 git add rep/one rep/two && 89 git commit -m Fourth && 90 git checkout main && 91 echo uno >rep/one && 92 echo dos >rep/two && 93 test_must_fail git checkout branch 2>out && 94 test_cmp out expect 95' 96 97cat >expect <<\EOF 98error: Your local changes to the following files would be overwritten by checkout: 99 rep/one 100 rep/two 101Please commit your changes or stash them before you switch branches. 102Aborting 103EOF 104 105test_expect_success 'not uptodate file porcelain checkout error' ' 106 git add rep/one rep/two && 107 test_must_fail git checkout branch 2>out && 108 test_cmp out expect 109' 110 111cat >expect <<\EOF 112error: Updating the following directories would lose untracked files in them: 113 rep 114 rep2 115 116Aborting 117EOF 118 119test_expect_success 'not_uptodate_dir porcelain checkout error' ' 120 git init uptodate && 121 cd uptodate && 122 mkdir rep && 123 mkdir rep2 && 124 touch rep/foo && 125 touch rep2/foo && 126 git add rep/foo rep2/foo && 127 git commit -m init && 128 git checkout -b branch && 129 git rm rep -r && 130 git rm rep2 -r && 131 >rep && 132 >rep2 && 133 git add rep rep2 && 134 git commit -m "added test as a file" && 135 git checkout main && 136 >rep/untracked-file && 137 >rep2/untracked-file && 138 test_must_fail git checkout branch 2>out && 139 test_cmp out ../expect 140' 141 142test_done