]>
Commit | Line | Data |
---|---|---|
35cc4bcd JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
5be60078 | 6 | test_description='git apply handling copy/rename patch. |
35cc4bcd JS |
7 | |
8 | ' | |
9 | . ./test-lib.sh | |
535d9742 | 10 | . "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh |
35cc4bcd JS |
11 | |
12 | # setup | |
13 | ||
14 | cat >test-patch <<\EOF | |
15 | diff --git a/foo b/bar | |
16 | similarity index 47% | |
e5a94313 JS |
17 | rename from foo |
18 | rename to bar | |
35cc4bcd JS |
19 | --- a/foo |
20 | +++ b/bar | |
21 | @@ -1 +1 @@ | |
22 | -This is foo | |
23 | +This is bar | |
24 | EOF | |
25 | ||
26 | echo 'This is foo' >foo | |
27 | chmod +x foo | |
28 | ||
29 | test_expect_success setup \ | |
5be60078 | 30 | 'git update-index --add foo' |
35cc4bcd JS |
31 | |
32 | test_expect_success apply \ | |
5be60078 | 33 | 'git apply --index --stat --summary --apply test-patch' |
35cc4bcd | 34 | |
872f349e JS |
35 | test_expect_success FILEMODE validate \ |
36 | 'test -f bar && ls -l bar | grep "^-..x......"' | |
37 | ||
e5a94313 | 38 | test_expect_success 'apply reverse' \ |
5be60078 | 39 | 'git apply -R --index --stat --summary --apply test-patch && |
e5a94313 JS |
40 | test "$(cat foo)" = "This is foo"' |
41 | ||
42 | cat >test-patch <<\EOF | |
43 | diff --git a/foo b/bar | |
44 | similarity index 47% | |
45 | copy from foo | |
46 | copy to bar | |
47 | --- a/foo | |
48 | +++ b/bar | |
49 | @@ -1 +1 @@ | |
50 | -This is foo | |
51 | +This is bar | |
52 | EOF | |
53 | ||
54 | test_expect_success 'apply copy' \ | |
5be60078 | 55 | 'git apply --index --stat --summary --apply test-patch && |
e5a94313 JS |
56 | test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"' |
57 | ||
35cc4bcd | 58 | test_done |