]>
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 | |
10 | ||
11 | # setup | |
12 | ||
13 | cat >test-patch <<\EOF | |
14 | diff --git a/foo b/bar | |
15 | similarity index 47% | |
e5a94313 JS |
16 | rename from foo |
17 | rename to bar | |
35cc4bcd JS |
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 \ | |
5be60078 | 29 | 'git update-index --add foo' |
35cc4bcd JS |
30 | |
31 | test_expect_success apply \ | |
5be60078 | 32 | 'git apply --index --stat --summary --apply test-patch' |
35cc4bcd | 33 | |
872f349e JS |
34 | test_expect_success FILEMODE validate \ |
35 | 'test -f bar && ls -l bar | grep "^-..x......"' | |
36 | ||
e5a94313 | 37 | test_expect_success 'apply reverse' \ |
5be60078 | 38 | 'git apply -R --index --stat --summary --apply test-patch && |
e5a94313 JS |
39 | test "$(cat foo)" = "This is foo"' |
40 | ||
41 | cat >test-patch <<\EOF | |
42 | diff --git a/foo b/bar | |
43 | similarity index 47% | |
44 | copy from foo | |
45 | copy to bar | |
46 | --- a/foo | |
47 | +++ b/bar | |
48 | @@ -1 +1 @@ | |
49 | -This is foo | |
50 | +This is bar | |
51 | EOF | |
52 | ||
53 | test_expect_success 'apply copy' \ | |
5be60078 | 54 | 'git apply --index --stat --summary --apply test-patch && |
4399345d | 55 | test "$(cat bar)" = "This is bar" && test "$(cat foo)" = "This is foo"' |
e5a94313 | 56 | |
35cc4bcd | 57 | test_done |