1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
56
test_description='git-apply handling copy/rename patch.
78
'
9. ./test-lib.sh
1011
# setup
1213
cat >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
2425
echo 'This is foo' >foo
26chmod +x foo
2728
test_expect_success setup \
29'git-update-index --add foo'
3031
test_expect_success apply \
32'git-apply --index --stat --summary --apply test-patch'
3334
if [ "$(git repo-config --get core.filemode)" = false ]
35then
36say 'filemode disabled on the filesystem'
37else
38test_expect_success validate \
39'test -f bar && ls -l bar | grep "^-..x......"'
40fi
4142
test_expect_success 'apply reverse' \
43'git-apply -R --index --stat --summary --apply test-patch &&
44test "$(cat foo)" = "This is foo"'
4546
cat >test-patch <<\EOF
47diff --git a/foo b/bar
48similarity index 47%
49copy from foo
50copy to bar
51--- a/foo
52+++ b/bar
53@@ -1 +1 @@
54-This is foo
55+This is bar
56EOF
5758
test_expect_success 'apply copy' \
59'git-apply --index --stat --summary --apply test-patch &&
60test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"'
6162
test_done