]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4102-apply-rename.sh
Merge branch 'gc/pull-recurse-submodules'
[thirdparty/git.git] / t / t4102-apply-rename.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='git apply handling copy/rename patch.
7
8 '
9
10 TEST_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
12
13 # setup
14
15 cat >test-patch <<\EOF
16 diff --git a/foo b/bar
17 similarity index 47%
18 rename from foo
19 rename to bar
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 \
31 'git update-index --add foo'
32
33 test_expect_success apply \
34 'git apply --index --stat --summary --apply test-patch'
35
36 test_expect_success FILEMODE validate \
37 'test -f bar && ls -l bar | grep "^-..x......"'
38
39 test_expect_success 'apply reverse' \
40 'git apply -R --index --stat --summary --apply test-patch &&
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' \
56 'git apply --index --stat --summary --apply test-patch &&
57 test "$(cat bar)" = "This is bar" && test "$(cat foo)" = "This is foo"'
58
59 test_done