Junio C Hamano | 032bea5 | 2008-05-17 02:02:44 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='apply empty' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success setup ' |
| 8 | >empty && |
| 9 | git add empty && |
| 10 | test_tick && |
| 11 | git commit -m initial && |
| 12 | for i in a b c d e |
| 13 | do |
| 14 | echo $i |
| 15 | done >empty && |
| 16 | cat empty >expect && |
| 17 | git diff | |
| 18 | sed -e "/^diff --git/d" \ |
| 19 | -e "/^index /d" \ |
| 20 | -e "s|a/empty|empty.orig|" \ |
| 21 | -e "s|b/empty|empty|" >patch0 && |
| 22 | sed -e "s|empty|missing|" patch0 >patch1 && |
| 23 | >empty && |
| 24 | git update-index --refresh |
| 25 | ' |
| 26 | |
| 27 | test_expect_success 'apply empty' ' |
| 28 | git reset --hard && |
Junio C Hamano | 032bea5 | 2008-05-17 02:02:44 -0700 | [diff] [blame] | 29 | rm -f missing && |
| 30 | git apply patch0 && |
| 31 | test_cmp expect empty |
| 32 | ' |
| 33 | |
| 34 | test_expect_success 'apply --index empty' ' |
| 35 | git reset --hard && |
Junio C Hamano | 032bea5 | 2008-05-17 02:02:44 -0700 | [diff] [blame] | 36 | rm -f missing && |
| 37 | git apply --index patch0 && |
| 38 | test_cmp expect empty && |
| 39 | git diff --exit-code |
| 40 | ' |
| 41 | |
| 42 | test_expect_success 'apply create' ' |
| 43 | git reset --hard && |
Junio C Hamano | 032bea5 | 2008-05-17 02:02:44 -0700 | [diff] [blame] | 44 | rm -f missing && |
| 45 | git apply patch1 && |
| 46 | test_cmp expect missing |
| 47 | ' |
| 48 | |
| 49 | test_expect_success 'apply --index create' ' |
| 50 | git reset --hard && |
Junio C Hamano | 032bea5 | 2008-05-17 02:02:44 -0700 | [diff] [blame] | 51 | rm -f missing && |
| 52 | git apply --index patch1 && |
| 53 | test_cmp expect missing && |
| 54 | git diff --exit-code |
| 55 | ' |
| 56 | |
| 57 | test_done |