Alexander Gladysh | f433f70 | 2010-07-09 07:10:52 -0600 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Test cherry-pick with directory/file conflicts' |
| 4 | . ./test-lib.sh |
| 5 | |
Pat Thoyts | 899663f | 2011-02-03 15:31:42 +0000 | [diff] [blame] | 6 | test_expect_success 'Initialize repository' ' |
Alexander Gladysh | f433f70 | 2010-07-09 07:10:52 -0600 | [diff] [blame] | 7 | mkdir a && |
| 8 | >a/f && |
| 9 | git add a && |
Pat Thoyts | 899663f | 2011-02-03 15:31:42 +0000 | [diff] [blame] | 10 | git commit -m a |
| 11 | ' |
Alexander Gladysh | f433f70 | 2010-07-09 07:10:52 -0600 | [diff] [blame] | 12 | |
Pat Thoyts | 899663f | 2011-02-03 15:31:42 +0000 | [diff] [blame] | 13 | test_expect_success SYMLINKS 'Setup rename across paths each below D/F conflicts' ' |
Alexander Gladysh | f433f70 | 2010-07-09 07:10:52 -0600 | [diff] [blame] | 14 | mkdir b && |
| 15 | ln -s ../a b/a && |
| 16 | git add b && |
| 17 | git commit -m b && |
| 18 | |
| 19 | git checkout -b branch && |
| 20 | rm b/a && |
| 21 | mv a b/a && |
| 22 | ln -s b/a a && |
| 23 | git add . && |
| 24 | git commit -m swap && |
| 25 | |
| 26 | >f1 && |
| 27 | git add f1 && |
| 28 | git commit -m f1 |
| 29 | ' |
| 30 | |
Elijah Newren | dd56858 | 2010-08-12 20:09:12 -0600 | [diff] [blame] | 31 | test_expect_success SYMLINKS 'Cherry-pick succeeds with rename across D/F conflicts' ' |
Alexander Gladysh | f433f70 | 2010-07-09 07:10:52 -0600 | [diff] [blame] | 32 | git reset --hard && |
| 33 | git checkout master^0 && |
| 34 | git cherry-pick branch |
| 35 | ' |
| 36 | |
Elijah Newren | 56bfd76 | 2010-09-08 00:40:40 -0600 | [diff] [blame] | 37 | test_expect_success 'Setup rename with file on one side matching directory name on other' ' |
| 38 | git checkout --orphan nick-testcase && |
| 39 | git rm -rf . && |
| 40 | |
| 41 | >empty && |
| 42 | git add empty && |
| 43 | git commit -m "Empty file" && |
| 44 | |
| 45 | git checkout -b simple && |
| 46 | mv empty file && |
| 47 | mkdir empty && |
| 48 | mv file empty && |
| 49 | git add empty/file && |
| 50 | git commit -m "Empty file under empty dir" && |
| 51 | |
| 52 | echo content >newfile && |
| 53 | git add newfile && |
| 54 | git commit -m "New file" |
| 55 | ' |
| 56 | |
| 57 | test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (resolve)' ' |
| 58 | git reset --hard && |
| 59 | git checkout -q nick-testcase^0 && |
| 60 | git cherry-pick --strategy=resolve simple |
| 61 | ' |
| 62 | |
Elijah Newren | 86273e5 | 2010-09-08 00:40:41 -0600 | [diff] [blame] | 63 | test_expect_success 'Cherry-pick succeeds with was_a_dir/file -> was_a_dir (recursive)' ' |
Elijah Newren | 56bfd76 | 2010-09-08 00:40:40 -0600 | [diff] [blame] | 64 | git reset --hard && |
| 65 | git checkout -q nick-testcase^0 && |
| 66 | git cherry-pick --strategy=recursive simple |
| 67 | ' |
| 68 | |
| 69 | test_expect_success 'Setup rename with file on one side matching different dirname on other' ' |
| 70 | git reset --hard && |
| 71 | git checkout --orphan mergeme && |
| 72 | git rm -rf . && |
| 73 | |
| 74 | mkdir sub && |
| 75 | mkdir othersub && |
| 76 | echo content > sub/file && |
| 77 | echo foo > othersub/whatever && |
| 78 | git add -A && |
| 79 | git commit -m "Common commmit" && |
| 80 | |
| 81 | git rm -rf othersub && |
| 82 | git mv sub/file othersub && |
| 83 | git commit -m "Commit to merge" && |
| 84 | |
| 85 | git checkout -b newhead mergeme~1 && |
| 86 | >independent-change && |
| 87 | git add independent-change && |
| 88 | git commit -m "Completely unrelated change" |
| 89 | ' |
| 90 | |
| 91 | test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (resolve)' ' |
| 92 | git reset --hard && |
| 93 | git checkout -q newhead^0 && |
| 94 | git cherry-pick --strategy=resolve mergeme |
| 95 | ' |
| 96 | |
Elijah Newren | 86273e5 | 2010-09-08 00:40:41 -0600 | [diff] [blame] | 97 | test_expect_success 'Cherry-pick with rename to different D/F conflict succeeds (recursive)' ' |
Elijah Newren | 56bfd76 | 2010-09-08 00:40:40 -0600 | [diff] [blame] | 98 | git reset --hard && |
| 99 | git checkout -q newhead^0 && |
| 100 | git cherry-pick --strategy=recursive mergeme |
| 101 | ' |
| 102 | |
Alexander Gladysh | f433f70 | 2010-07-09 07:10:52 -0600 | [diff] [blame] | 103 | test_done |