Let t0000 pass on Windows again
[git/dscho.git] / t / t4114-apply-typechange.sh
blobe400db58abd47976e0b50bc19723ee7bf1e5bee5
1 #!/bin/sh
3 # Copyright (c) 2006 Eric Wong
6 test_description='git apply should not get confused with type changes.
10 . ./test-lib.sh
12 test "$no_symlinks" && {
13 say "Symbolic links not supported - skipping tests"
14 test_done
17 test_expect_success 'setup repository and commits' '
18 echo "hello world" > foo &&
19 echo "hi planet" > bar &&
20 git update-index --add foo bar &&
21 git commit -m initial &&
22 git branch initial &&
23 rm -f foo &&
24 ln -s bar foo &&
25 git update-index foo &&
26 git commit -m "foo symlinked to bar" &&
27 git branch foo-symlinked-to-bar &&
28 rm -f foo &&
29 echo "how far is the sun?" > foo &&
30 git update-index foo &&
31 git commit -m "foo back to file" &&
32 git branch foo-back-to-file &&
33 printf "\0" > foo &&
34 git update-index foo &&
35 git commit -m "foo becomes binary" &&
36 git branch foo-becomes-binary &&
37 rm -f foo &&
38 git update-index --remove foo &&
39 mkdir foo &&
40 echo "if only I knew" > foo/baz &&
41 git update-index --add foo/baz &&
42 git commit -m "foo becomes a directory" &&
43 git branch "foo-becomes-a-directory" &&
44 echo "hello world" > foo/baz &&
45 git update-index foo/baz &&
46 git commit -m "foo/baz is the original foo" &&
47 git branch foo-baz-renamed-from-foo
50 test_expect_success 'file renamed from foo to foo/baz' '
51 git checkout -f initial &&
52 git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
53 git apply --index < patch
55 test_debug 'cat patch'
58 test_expect_success 'file renamed from foo/baz to foo' '
59 git checkout -f foo-baz-renamed-from-foo &&
60 git diff-tree -M -p HEAD initial > patch &&
61 git apply --index < patch
63 test_debug 'cat patch'
66 test_expect_success 'directory becomes file' '
67 git checkout -f foo-becomes-a-directory &&
68 git diff-tree -p HEAD initial > patch &&
69 git apply --index < patch
71 test_debug 'cat patch'
74 test_expect_success 'file becomes directory' '
75 git checkout -f initial &&
76 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
77 git apply --index < patch
79 test_debug 'cat patch'
82 test_expect_success 'file becomes symlink' '
83 git checkout -f initial &&
84 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
85 git apply --index < patch
87 test_debug 'cat patch'
90 test_expect_success 'symlink becomes file' '
91 git checkout -f foo-symlinked-to-bar &&
92 git diff-tree -p HEAD foo-back-to-file > patch &&
93 git apply --index < patch
95 test_debug 'cat patch'
97 test_expect_success 'binary file becomes symlink' '
98 git checkout -f foo-becomes-binary &&
99 git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch &&
100 git apply --index < patch
102 test_debug 'cat patch'
104 test_expect_success 'symlink becomes binary file' '
105 git checkout -f foo-symlinked-to-bar &&
106 git diff-tree -p --binary HEAD foo-becomes-binary > patch &&
107 git apply --index < patch
109 test_debug 'cat patch'
112 test_expect_success 'symlink becomes directory' '
113 git checkout -f foo-symlinked-to-bar &&
114 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
115 git apply --index < patch
117 test_debug 'cat patch'
120 test_expect_success 'directory becomes symlink' '
121 git checkout -f foo-becomes-a-directory &&
122 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
123 git apply --index < patch
125 test_debug 'cat patch'
128 test_done