]>
Commit | Line | Data |
---|---|---|
8641fb24 EW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Eric Wong | |
4 | # | |
5 | ||
5be60078 | 6 | test_description='git apply should not get confused with type changes. |
8641fb24 EW |
7 | |
8 | ' | |
9 | ||
10 | . ./test-lib.sh | |
11 | ||
704a3143 JS |
12 | if ! test_have_prereq SYMLINKS |
13 | then | |
14 | say 'Symbolic links not supported, skipping tests.' | |
15 | test_done | |
16 | exit | |
17 | fi | |
18 | ||
8641fb24 EW |
19 | test_expect_success 'setup repository and commits' ' |
20 | echo "hello world" > foo && | |
21 | echo "hi planet" > bar && | |
22 | git update-index --add foo bar && | |
23 | git commit -m initial && | |
24 | git branch initial && | |
25 | rm -f foo && | |
26 | ln -s bar foo && | |
27 | git update-index foo && | |
28 | git commit -m "foo symlinked to bar" && | |
29 | git branch foo-symlinked-to-bar && | |
30 | rm -f foo && | |
31 | echo "how far is the sun?" > foo && | |
32 | git update-index foo && | |
33 | git commit -m "foo back to file" && | |
34 | git branch foo-back-to-file && | |
b67b9612 JH |
35 | printf "\0" > foo && |
36 | git update-index foo && | |
37 | git commit -m "foo becomes binary" && | |
38 | git branch foo-becomes-binary && | |
8641fb24 EW |
39 | rm -f foo && |
40 | git update-index --remove foo && | |
41 | mkdir foo && | |
42 | echo "if only I knew" > foo/baz && | |
43 | git update-index --add foo/baz && | |
44 | git commit -m "foo becomes a directory" && | |
45 | git branch "foo-becomes-a-directory" && | |
46 | echo "hello world" > foo/baz && | |
47 | git update-index foo/baz && | |
48 | git commit -m "foo/baz is the original foo" && | |
49 | git branch foo-baz-renamed-from-foo | |
50 | ' | |
51 | ||
52 | test_expect_success 'file renamed from foo to foo/baz' ' | |
53 | git checkout -f initial && | |
54 | git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch && | |
55 | git apply --index < patch | |
56 | ' | |
57 | test_debug 'cat patch' | |
58 | ||
59 | ||
60 | test_expect_success 'file renamed from foo/baz to foo' ' | |
61 | git checkout -f foo-baz-renamed-from-foo && | |
62 | git diff-tree -M -p HEAD initial > patch && | |
63 | git apply --index < patch | |
64 | ' | |
65 | test_debug 'cat patch' | |
66 | ||
67 | ||
68 | test_expect_success 'directory becomes file' ' | |
69 | git checkout -f foo-becomes-a-directory && | |
70 | git diff-tree -p HEAD initial > patch && | |
71 | git apply --index < patch | |
72 | ' | |
73 | test_debug 'cat patch' | |
74 | ||
75 | ||
76 | test_expect_success 'file becomes directory' ' | |
77 | git checkout -f initial && | |
78 | git diff-tree -p HEAD foo-becomes-a-directory > patch && | |
79 | git apply --index < patch | |
80 | ' | |
81 | test_debug 'cat patch' | |
82 | ||
83 | ||
84 | test_expect_success 'file becomes symlink' ' | |
85 | git checkout -f initial && | |
86 | git diff-tree -p HEAD foo-symlinked-to-bar > patch && | |
87 | git apply --index < patch | |
88 | ' | |
89 | test_debug 'cat patch' | |
90 | ||
91 | ||
92 | test_expect_success 'symlink becomes file' ' | |
93 | git checkout -f foo-symlinked-to-bar && | |
94 | git diff-tree -p HEAD foo-back-to-file > patch && | |
95 | git apply --index < patch | |
96 | ' | |
97 | test_debug 'cat patch' | |
98 | ||
b67b9612 JH |
99 | test_expect_success 'binary file becomes symlink' ' |
100 | git checkout -f foo-becomes-binary && | |
101 | git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch && | |
102 | git apply --index < patch | |
103 | ' | |
104 | test_debug 'cat patch' | |
105 | ||
106 | test_expect_success 'symlink becomes binary file' ' | |
107 | git checkout -f foo-symlinked-to-bar && | |
108 | git diff-tree -p --binary HEAD foo-becomes-binary > patch && | |
109 | git apply --index < patch | |
110 | ' | |
111 | test_debug 'cat patch' | |
112 | ||
8641fb24 EW |
113 | |
114 | test_expect_success 'symlink becomes directory' ' | |
115 | git checkout -f foo-symlinked-to-bar && | |
116 | git diff-tree -p HEAD foo-becomes-a-directory > patch && | |
117 | git apply --index < patch | |
118 | ' | |
119 | test_debug 'cat patch' | |
120 | ||
121 | ||
122 | test_expect_success 'directory becomes symlink' ' | |
123 | git checkout -f foo-becomes-a-directory && | |
124 | git diff-tree -p HEAD foo-symlinked-to-bar > patch && | |
125 | git apply --index < patch | |
126 | ' | |
127 | test_debug 'cat patch' | |
128 | ||
129 | ||
130 | test_done |