Makefile: customization for supporting HP-UX
[git/fastimport.git] / t / t4102-apply-rename.sh
blobd42abff1ad59343fa1c84bded9a82c3212370da0
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 [ "$(git config --get core.filemode)" = false ]
35 then
36 say 'filemode disabled on the filesystem'
37 else
38 test_expect_success validate \
39 'test -f bar && ls -l bar | grep "^-..x......"'
42 test_expect_success 'apply reverse' \
43 'git apply -R --index --stat --summary --apply test-patch &&
44 test "$(cat foo)" = "This is foo"'
46 cat >test-patch <<\EOF
47 diff --git a/foo b/bar
48 similarity index 47%
49 copy from foo
50 copy to bar
51 --- a/foo
52 +++ b/bar
53 @@ -1 +1 @@
54 -This is foo
55 +This is bar
56 EOF
58 test_expect_success 'apply copy' \
59 'git apply --index --stat --summary --apply test-patch &&
60 test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"'
62 test_done