]>
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 | ||
41be8ea2 | 12 | test_expect_success SYMLINKS 'setup repository and commits' ' |
8641fb24 EW |
13 | echo "hello world" > foo && |
14 | echo "hi planet" > bar && | |
15 | git update-index --add foo bar && | |
16 | git commit -m initial && | |
17 | git branch initial && | |
18 | rm -f foo && | |
19 | ln -s bar foo && | |
20 | git update-index foo && | |
21 | git commit -m "foo symlinked to bar" && | |
22 | git branch foo-symlinked-to-bar && | |
23 | rm -f foo && | |
24 | echo "how far is the sun?" > foo && | |
25 | git update-index foo && | |
26 | git commit -m "foo back to file" && | |
27 | git branch foo-back-to-file && | |
b67b9612 JH |
28 | printf "\0" > foo && |
29 | git update-index foo && | |
30 | git commit -m "foo becomes binary" && | |
31 | git branch foo-becomes-binary && | |
8641fb24 EW |
32 | rm -f foo && |
33 | git update-index --remove foo && | |
34 | mkdir foo && | |
35 | echo "if only I knew" > foo/baz && | |
36 | git update-index --add foo/baz && | |
37 | git commit -m "foo becomes a directory" && | |
38 | git branch "foo-becomes-a-directory" && | |
39 | echo "hello world" > foo/baz && | |
40 | git update-index foo/baz && | |
41 | git commit -m "foo/baz is the original foo" && | |
42 | git branch foo-baz-renamed-from-foo | |
43 | ' | |
44 | ||
41be8ea2 | 45 | test_expect_success SYMLINKS 'file renamed from foo to foo/baz' ' |
8641fb24 EW |
46 | git checkout -f initial && |
47 | git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch && | |
48 | git apply --index < patch | |
49 | ' | |
50 | test_debug 'cat patch' | |
51 | ||
52 | ||
41be8ea2 | 53 | test_expect_success SYMLINKS 'file renamed from foo/baz to foo' ' |
8641fb24 EW |
54 | git checkout -f foo-baz-renamed-from-foo && |
55 | git diff-tree -M -p HEAD initial > patch && | |
56 | git apply --index < patch | |
57 | ' | |
58 | test_debug 'cat patch' | |
59 | ||
60 | ||
41be8ea2 | 61 | test_expect_success SYMLINKS 'directory becomes file' ' |
8641fb24 EW |
62 | git checkout -f foo-becomes-a-directory && |
63 | git diff-tree -p HEAD initial > patch && | |
64 | git apply --index < patch | |
65 | ' | |
66 | test_debug 'cat patch' | |
67 | ||
68 | ||
41be8ea2 | 69 | test_expect_success SYMLINKS 'file becomes directory' ' |
8641fb24 EW |
70 | git checkout -f initial && |
71 | git diff-tree -p HEAD foo-becomes-a-directory > patch && | |
72 | git apply --index < patch | |
73 | ' | |
74 | test_debug 'cat patch' | |
75 | ||
76 | ||
41be8ea2 | 77 | test_expect_success SYMLINKS 'file becomes symlink' ' |
8641fb24 EW |
78 | git checkout -f initial && |
79 | git diff-tree -p HEAD foo-symlinked-to-bar > patch && | |
80 | git apply --index < patch | |
81 | ' | |
82 | test_debug 'cat patch' | |
83 | ||
84 | ||
41be8ea2 | 85 | test_expect_success SYMLINKS 'symlink becomes file' ' |
8641fb24 EW |
86 | git checkout -f foo-symlinked-to-bar && |
87 | git diff-tree -p HEAD foo-back-to-file > patch && | |
88 | git apply --index < patch | |
89 | ' | |
90 | test_debug 'cat patch' | |
91 | ||
41be8ea2 | 92 | test_expect_success SYMLINKS 'binary file becomes symlink' ' |
b67b9612 JH |
93 | git checkout -f foo-becomes-binary && |
94 | git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch && | |
95 | git apply --index < patch | |
96 | ' | |
97 | test_debug 'cat patch' | |
98 | ||
41be8ea2 | 99 | test_expect_success SYMLINKS 'symlink becomes binary file' ' |
b67b9612 JH |
100 | git checkout -f foo-symlinked-to-bar && |
101 | git diff-tree -p --binary HEAD foo-becomes-binary > patch && | |
102 | git apply --index < patch | |
103 | ' | |
104 | test_debug 'cat patch' | |
105 | ||
8641fb24 | 106 | |
41be8ea2 | 107 | test_expect_success SYMLINKS 'symlink becomes directory' ' |
8641fb24 EW |
108 | git checkout -f foo-symlinked-to-bar && |
109 | git diff-tree -p HEAD foo-becomes-a-directory > patch && | |
110 | git apply --index < patch | |
111 | ' | |
112 | test_debug 'cat patch' | |
113 | ||
114 | ||
41be8ea2 | 115 | test_expect_success SYMLINKS 'directory becomes symlink' ' |
8641fb24 EW |
116 | git checkout -f foo-becomes-a-directory && |
117 | git diff-tree -p HEAD foo-symlinked-to-bar > patch && | |
118 | git apply --index < patch | |
119 | ' | |
120 | test_debug 'cat patch' | |
121 | ||
122 | ||
123 | test_done |