Merge branch 'seq-builtin-dev' into mymaster
[git/sbeyer.git] / t / t4114-apply-typechange.sh
blob99ec13dd531c71299681acc3eb678b490ff68707
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 if ! test_have_prereq SYMLINKS
13 then
14 say 'Symbolic links not supported, skipping tests.'
15 test_done
18 test_expect_success 'setup repository and commits' '
19 echo "hello world" > foo &&
20 echo "hi planet" > bar &&
21 git update-index --add foo bar &&
22 git commit -m initial &&
23 git branch initial &&
24 rm -f foo &&
25 ln -s bar foo &&
26 git update-index foo &&
27 git commit -m "foo symlinked to bar" &&
28 git branch foo-symlinked-to-bar &&
29 rm -f foo &&
30 echo "how far is the sun?" > foo &&
31 git update-index foo &&
32 git commit -m "foo back to file" &&
33 git branch foo-back-to-file &&
34 printf "\0" > foo &&
35 git update-index foo &&
36 git commit -m "foo becomes binary" &&
37 git branch foo-becomes-binary &&
38 rm -f foo &&
39 git update-index --remove foo &&
40 mkdir foo &&
41 echo "if only I knew" > foo/baz &&
42 git update-index --add foo/baz &&
43 git commit -m "foo becomes a directory" &&
44 git branch "foo-becomes-a-directory" &&
45 echo "hello world" > foo/baz &&
46 git update-index foo/baz &&
47 git commit -m "foo/baz is the original foo" &&
48 git branch foo-baz-renamed-from-foo
51 test_expect_success 'file renamed from foo to foo/baz' '
52 git checkout -f initial &&
53 git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
54 git apply --index < patch
56 test_debug 'cat patch'
59 test_expect_success 'file renamed from foo/baz to foo' '
60 git checkout -f foo-baz-renamed-from-foo &&
61 git diff-tree -M -p HEAD initial > patch &&
62 git apply --index < patch
64 test_debug 'cat patch'
67 test_expect_success 'directory becomes file' '
68 git checkout -f foo-becomes-a-directory &&
69 git diff-tree -p HEAD initial > patch &&
70 git apply --index < patch
72 test_debug 'cat patch'
75 test_expect_success 'file becomes directory' '
76 git checkout -f initial &&
77 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
78 git apply --index < patch
80 test_debug 'cat patch'
83 test_expect_success 'file becomes symlink' '
84 git checkout -f initial &&
85 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
86 git apply --index < patch
88 test_debug 'cat patch'
91 test_expect_success 'symlink becomes file' '
92 git checkout -f foo-symlinked-to-bar &&
93 git diff-tree -p HEAD foo-back-to-file > patch &&
94 git apply --index < patch
96 test_debug 'cat patch'
98 test_expect_success 'binary file becomes symlink' '
99 git checkout -f foo-becomes-binary &&
100 git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch &&
101 git apply --index < patch
103 test_debug 'cat patch'
105 test_expect_success 'symlink becomes binary file' '
106 git checkout -f foo-symlinked-to-bar &&
107 git diff-tree -p --binary HEAD foo-becomes-binary > patch &&
108 git apply --index < patch
110 test_debug 'cat patch'
113 test_expect_success 'symlink becomes directory' '
114 git checkout -f foo-symlinked-to-bar &&
115 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
116 git apply --index < patch
118 test_debug 'cat patch'
121 test_expect_success 'directory becomes symlink' '
122 git checkout -f foo-becomes-a-directory &&
123 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
124 git apply --index < patch
126 test_debug 'cat patch'
129 test_done