]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4102-apply-rename.sh
t3600: Use test prerequisite tags
[thirdparty/git.git] / t / t4102-apply-rename.sh
CommitLineData
35cc4bcd
JS
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
5be60078 6test_description='git apply handling copy/rename patch.
35cc4bcd
JS
7
8'
9. ./test-lib.sh
10
11# setup
12
13cat >test-patch <<\EOF
14diff --git a/foo b/bar
15similarity index 47%
e5a94313
JS
16rename from foo
17rename to bar
35cc4bcd
JS
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 \
5be60078 29 'git update-index --add foo'
35cc4bcd
JS
30
31test_expect_success apply \
5be60078 32 'git apply --index --stat --summary --apply test-patch'
35cc4bcd 33
e0d10e1c 34if [ "$(git config --get core.filemode)" = false ]
b484ef28
AR
35then
36 say 'filemode disabled on the filesystem'
37else
38 test_expect_success validate \
39 'test -f bar && ls -l bar | grep "^-..x......"'
40fi
35cc4bcd 41
e5a94313 42test_expect_success 'apply reverse' \
5be60078 43 'git apply -R --index --stat --summary --apply test-patch &&
e5a94313
JS
44 test "$(cat foo)" = "This is foo"'
45
46cat >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
57
58test_expect_success 'apply copy' \
5be60078 59 'git apply --index --stat --summary --apply test-patch &&
e5a94313
JS
60 test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"'
61
35cc4bcd 62test_done