debian: apply upstream changes to avoid v2.45.1 being a regression
[git/debian.git] / t / t4102-apply-rename.sh
blobd1e06fc1ac41354d9a50d6db76663f0b9ff3e698
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git apply handling copy/rename patch.
10 TEST_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
13 # setup
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
27 echo 'This is foo' >foo
28 chmod +x foo
30 test_expect_success setup \
31 'git update-index --add foo'
33 test_expect_success apply \
34 'git apply --index --stat --summary --apply test-patch'
36 test_expect_success FILEMODE validate \
37 'test -f bar && ls -l bar | grep "^-..x......"'
39 test_expect_success 'apply reverse' \
40 'git apply -R --index --stat --summary --apply test-patch &&
41 test "$(cat foo)" = "This is foo"'
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
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"'
59 test_done