| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2006 Junio C Hamano |
| 4 | # |
| 5 | |
| 6 | test_description='git apply with new style GNU diff with empty context |
| 7 | |
| 8 | ' |
| 9 | |
| 10 | |
| 11 | . ./test-lib.sh |
| 12 | |
| 13 | test_expect_success setup ' |
| 14 | test_write_lines "" "" A B C "" >file1 && |
| 15 | cat file1 >file1.orig && |
| 16 | { |
| 17 | cat file1 && |
| 18 | echo Q | tr -d "\\012" |
| 19 | } >file2 && |
| 20 | cat file2 >file2.orig && |
| 21 | git add file1 file2 && |
| 22 | sed -e "/^B/d" <file1.orig >file1 && |
| 23 | cat file1 > file2 && |
| 24 | echo Q | tr -d "\\012" >>file2 && |
| 25 | cat file1 >file1.mods && |
| 26 | cat file2 >file2.mods && |
| 27 | git diff | |
| 28 | sed -e "s/^ \$//" >diff.output |
| 29 | ' |
| 30 | |
| 31 | test_expect_success 'apply --numstat' ' |
| 32 | |
| 33 | git apply --numstat diff.output >actual && |
| 34 | { |
| 35 | echo "0 1 file1" && |
| 36 | echo "0 1 file2" |
| 37 | } >expect && |
| 38 | test_cmp expect actual |
| 39 | |
| 40 | ' |
| 41 | |
| 42 | test_expect_success 'apply --apply' ' |
| 43 | |
| 44 | cat file1.orig >file1 && |
| 45 | cat file2.orig >file2 && |
| 46 | git update-index file1 file2 && |
| 47 | git apply --index diff.output && |
| 48 | test_cmp file1.mods file1 && |
| 49 | test_cmp file2.mods file2 |
| 50 | ' |
| 51 | |
| 52 | test_done |