Johannes Schindelin | 35cc4bc | 2005-08-17 09:01:07 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2005 Junio C Hamano |
| 4 | # |
| 5 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 6 | test_description='git apply handling copy/rename patch. |
Johannes Schindelin | 35cc4bc | 2005-08-17 09:01:07 +0200 | [diff] [blame] | 7 | |
| 8 | ' |
| 9 | . ./test-lib.sh |
| 10 | |
| 11 | # setup |
| 12 | |
| 13 | cat >test-patch <<\EOF |
| 14 | diff --git a/foo b/bar |
| 15 | similarity index 47% |
Johannes Schindelin | e5a9431 | 2006-07-28 17:46:11 +0200 | [diff] [blame] | 16 | rename from foo |
| 17 | rename to bar |
Johannes Schindelin | 35cc4bc | 2005-08-17 09:01:07 +0200 | [diff] [blame] | 18 | --- a/foo |
| 19 | +++ b/bar |
| 20 | @@ -1 +1 @@ |
| 21 | -This is foo |
| 22 | +This is bar |
| 23 | EOF |
| 24 | |
| 25 | echo 'This is foo' >foo |
| 26 | chmod +x foo |
| 27 | |
| 28 | test_expect_success setup \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 29 | 'git update-index --add foo' |
Johannes Schindelin | 35cc4bc | 2005-08-17 09:01:07 +0200 | [diff] [blame] | 30 | |
| 31 | test_expect_success apply \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 32 | 'git apply --index --stat --summary --apply test-patch' |
Johannes Schindelin | 35cc4bc | 2005-08-17 09:01:07 +0200 | [diff] [blame] | 33 | |
Tom Prince | e0d10e1 | 2007-01-28 16:16:53 -0800 | [diff] [blame] | 34 | if [ "$(git config --get core.filemode)" = false ] |
Alex Riesen | b484ef2 | 2006-01-05 12:55:58 +0100 | [diff] [blame] | 35 | then |
| 36 | say 'filemode disabled on the filesystem' |
| 37 | else |
| 38 | test_expect_success validate \ |
| 39 | 'test -f bar && ls -l bar | grep "^-..x......"' |
| 40 | fi |
Johannes Schindelin | 35cc4bc | 2005-08-17 09:01:07 +0200 | [diff] [blame] | 41 | |
Johannes Schindelin | e5a9431 | 2006-07-28 17:46:11 +0200 | [diff] [blame] | 42 | test_expect_success 'apply reverse' \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 43 | 'git apply -R --index --stat --summary --apply test-patch && |
Johannes Schindelin | e5a9431 | 2006-07-28 17:46:11 +0200 | [diff] [blame] | 44 | test "$(cat foo)" = "This is foo"' |
| 45 | |
| 46 | cat >test-patch <<\EOF |
| 47 | diff --git a/foo b/bar |
| 48 | similarity index 47% |
| 49 | copy from foo |
| 50 | copy to bar |
| 51 | --- a/foo |
| 52 | +++ b/bar |
| 53 | @@ -1 +1 @@ |
| 54 | -This is foo |
| 55 | +This is bar |
| 56 | EOF |
| 57 | |
| 58 | test_expect_success 'apply copy' \ |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 59 | 'git apply --index --stat --summary --apply test-patch && |
Johannes Schindelin | e5a9431 | 2006-07-28 17:46:11 +0200 | [diff] [blame] | 60 | test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"' |
| 61 | |
Johannes Schindelin | 35cc4bc | 2005-08-17 09:01:07 +0200 | [diff] [blame] | 62 | test_done |