Johannes Schindelin | f95ebf7 | 2008-07-04 16:19:52 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Jeff King | e9fe74c | 2011-05-12 07:10:07 -0400 | [diff] [blame] | 3 | test_description='test cherry-picking (and reverting) a root commit' |
Johannes Schindelin | f95ebf7 | 2008-07-04 16:19:52 +0100 | [diff] [blame] | 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success setup ' |
| 8 | |
| 9 | echo first > file1 && |
| 10 | git add file1 && |
| 11 | test_tick && |
| 12 | git commit -m "first" && |
| 13 | |
| 14 | git symbolic-ref HEAD refs/heads/second && |
| 15 | rm .git/index file1 && |
| 16 | echo second > file2 && |
| 17 | git add file2 && |
| 18 | test_tick && |
Jonathan Nieder | 127f045 | 2011-08-14 10:22:04 -0500 | [diff] [blame] | 19 | git commit -m "second" && |
| 20 | |
| 21 | git symbolic-ref HEAD refs/heads/third && |
| 22 | rm .git/index file2 && |
| 23 | echo third > file3 && |
| 24 | git add file3 && |
| 25 | test_tick && |
| 26 | git commit -m "third" |
Johannes Schindelin | f95ebf7 | 2008-07-04 16:19:52 +0100 | [diff] [blame] | 27 | |
| 28 | ' |
| 29 | |
| 30 | test_expect_success 'cherry-pick a root commit' ' |
| 31 | |
Jonathan Nieder | 127f045 | 2011-08-14 10:22:04 -0500 | [diff] [blame] | 32 | git checkout second^0 && |
Johannes Schindelin | f95ebf7 | 2008-07-04 16:19:52 +0100 | [diff] [blame] | 33 | git cherry-pick master && |
Jeff King | e9fe74c | 2011-05-12 07:10:07 -0400 | [diff] [blame] | 34 | echo first >expect && |
| 35 | test_cmp expect file1 |
| 36 | |
| 37 | ' |
| 38 | |
| 39 | test_expect_success 'revert a root commit' ' |
| 40 | |
| 41 | git revert master && |
| 42 | test_path_is_missing file1 |
| 43 | |
| 44 | ' |
| 45 | |
| 46 | test_expect_success 'cherry-pick a root commit with an external strategy' ' |
| 47 | |
| 48 | git cherry-pick --strategy=resolve master && |
| 49 | echo first >expect && |
| 50 | test_cmp expect file1 |
| 51 | |
| 52 | ' |
| 53 | |
| 54 | test_expect_success 'revert a root commit with an external strategy' ' |
| 55 | |
| 56 | git revert --strategy=resolve master && |
| 57 | test_path_is_missing file1 |
Johannes Schindelin | f95ebf7 | 2008-07-04 16:19:52 +0100 | [diff] [blame] | 58 | |
| 59 | ' |
| 60 | |
Jonathan Nieder | 127f045 | 2011-08-14 10:22:04 -0500 | [diff] [blame] | 61 | test_expect_success 'cherry-pick two root commits' ' |
| 62 | |
| 63 | echo first >expect.file1 && |
| 64 | echo second >expect.file2 && |
| 65 | echo third >expect.file3 && |
| 66 | |
| 67 | git checkout second^0 && |
| 68 | git cherry-pick master third && |
| 69 | |
| 70 | test_cmp expect.file1 file1 && |
| 71 | test_cmp expect.file2 file2 && |
| 72 | test_cmp expect.file3 file3 && |
| 73 | git rev-parse --verify HEAD^^ && |
| 74 | test_must_fail git rev-parse --verify HEAD^^^ |
| 75 | |
| 76 | ' |
| 77 | |
Johannes Schindelin | f95ebf7 | 2008-07-04 16:19:52 +0100 | [diff] [blame] | 78 | test_done |