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