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