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