summaryrefslogtreecommitdiff
path: root/tests/criss-cross
blob: 5e7b611fa8451f39c5b0027a118077160af53626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Copyright (C) 2010-2012 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# in any medium, are permitted without royalty provided the copyright
# notice and this notice are preserved.

# git diffs: criss-cross renames

. $srcdir/test-lib.sh

require cat
use_local_patch
use_tmpdir

# ==============================================================
# Criss-cross rename

echo 1 > f
echo 2 > g

cat > criss-cross-rename.diff <<EOF
diff --git a/g b/f
similarity index 100%
rename from g
rename to f
diff --git a/f b/g
similarity index 100%
rename from f
rename to g
EOF

check 'patch -p1 < criss-cross-rename.diff || echo "Status: $?"' <<EOF
patching file f (renamed from g)
patching file g (renamed from f)
EOF

check 'cat f' <<EOF
2
EOF

check 'cat g' <<EOF
1
EOF

# ==============================================================
# Copy-after-modify test case

ncheck 'seq 1 1000 > a'

cat > modified-twice.diff <<EOF
diff --git a/a b/a
index 1179824..912fcbd 100644
--- a/a
+++ b/a
@@ -998,3 +998,4 @@
 998
 999
 1000
+a
diff --git a/a b/b
similarity index 99%
copy from a
copy to b
index 1179824..1c5afa7 100644
--- a/a
+++ b/b
@@ -998,3 +998,4 @@
 998
 999
 1000
+b
EOF

check 'patch -p1 < modified-twice.diff || echo "Status: $?"' <<EOF
patching file a
patching file b (copied from a)
EOF

check 'cat a' <<EOF
`seq 1 1000`
a
EOF
check 'cat b' <<EOF
`seq 1 1000`
b
EOF