]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4102-apply-rename.sh
t2024: Fix &&-chaining and a couple of typos
[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'
9. ./test-lib.sh
535d9742 10. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
35cc4bcd
JS
11
12# setup
13
14cat >test-patch <<\EOF
15diff --git a/foo b/bar
16similarity index 47%
e5a94313
JS
17rename from foo
18rename to bar
35cc4bcd
JS
19--- a/foo
20+++ b/bar
21@@ -1 +1 @@
22-This is foo
23+This is bar
24EOF
25
26echo 'This is foo' >foo
27chmod +x foo
28
29test_expect_success setup \
5be60078 30 'git update-index --add foo'
35cc4bcd
JS
31
32test_expect_success apply \
5be60078 33 'git apply --index --stat --summary --apply test-patch'
35cc4bcd 34
872f349e
JS
35test_expect_success FILEMODE validate \
36 'test -f bar && ls -l bar | grep "^-..x......"'
37
e5a94313 38test_expect_success 'apply reverse' \
5be60078 39 'git apply -R --index --stat --summary --apply test-patch &&
e5a94313
JS
40 test "$(cat foo)" = "This is foo"'
41
42cat >test-patch <<\EOF
43diff --git a/foo b/bar
44similarity index 47%
45copy from foo
46copy to bar
47--- a/foo
48+++ b/bar
49@@ -1 +1 @@
50-This is foo
51+This is bar
52EOF
53
54test_expect_success 'apply copy' \
5be60078 55 'git apply --index --stat --summary --apply test-patch &&
e5a94313
JS
56 test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"'
57
35cc4bcd 58test_done