grep: simplify -p output
[git/vmiklos.git] / t / t4102-apply-rename.sh
blob1597965241c3566aa3a14e986fd5a630fb348479
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git apply handling copy/rename patch.
9 . ./test-lib.sh
11 # setup
13 cat >test-patch <<\EOF
14 diff --git a/foo b/bar
15 similarity index 47%
16 rename from foo
17 rename to bar
18 --- a/foo
19 +++ b/bar
20 @@ -1 +1 @@
21 -This is foo
22 +This is bar
23 EOF
25 echo 'This is foo' >foo
26 chmod +x foo
28 test_expect_success setup \
29 'git update-index --add foo'
31 test_expect_success apply \
32 'git apply --index --stat --summary --apply test-patch'
34 if test "$(git config --bool core.filemode)" = false
35 then
36 say 'filemode disabled on the filesystem'
37 else
38 test_set_prereq FILEMODE
41 test_expect_success FILEMODE validate \
42 'test -f bar && ls -l bar | grep "^-..x......"'
44 test_expect_success 'apply reverse' \
45 'git apply -R --index --stat --summary --apply test-patch &&
46 test "$(cat foo)" = "This is foo"'
48 cat >test-patch <<\EOF
49 diff --git a/foo b/bar
50 similarity index 47%
51 copy from foo
52 copy to bar
53 --- a/foo
54 +++ b/bar
55 @@ -1 +1 @@
56 -This is foo
57 +This is bar
58 EOF
60 test_expect_success 'apply copy' \
61 'git apply --index --stat --summary --apply test-patch &&
62 test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"'
64 test_done