Merge branch 'dl/stash-show-untracked-fixup'
[alt-git.git] / t / t4114-apply-typechange.sh
blobda3e64f8110d54d7243c017a9a614baa7098142f
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_expect_success 'setup repository and commits' '
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 test_ln_s_add bar foo &&
20 git commit -m "foo symlinked to bar" &&
21 git branch foo-symlinked-to-bar &&
22 git rm -f foo &&
23 echo "how far is the sun?" > foo &&
24 git update-index --add foo &&
25 git commit -m "foo back to file" &&
26 git branch foo-back-to-file &&
27 printf "\0" > foo &&
28 git update-index foo &&
29 git commit -m "foo becomes binary" &&
30 git branch foo-becomes-binary &&
31 rm -f foo &&
32 git update-index --remove foo &&
33 mkdir foo &&
34 echo "if only I knew" > foo/baz &&
35 git update-index --add foo/baz &&
36 git commit -m "foo becomes a directory" &&
37 git branch "foo-becomes-a-directory" &&
38 echo "hello world" > foo/baz &&
39 git update-index foo/baz &&
40 git commit -m "foo/baz is the original foo" &&
41 git branch foo-baz-renamed-from-foo
44 test_expect_success 'file renamed from foo to foo/baz' '
45 git checkout -f initial &&
46 git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
47 git apply --index < patch
49 test_debug 'cat patch'
52 test_expect_success 'file renamed from foo/baz to foo' '
53 git checkout -f foo-baz-renamed-from-foo &&
54 git diff-tree -M -p HEAD initial > patch &&
55 git apply --index < patch
57 test_debug 'cat patch'
60 test_expect_success 'directory becomes file' '
61 git checkout -f foo-becomes-a-directory &&
62 git diff-tree -p HEAD initial > patch &&
63 git apply --index < patch
65 test_debug 'cat patch'
68 test_expect_success 'file becomes directory' '
69 git checkout -f initial &&
70 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
71 git apply --index < patch
73 test_debug 'cat patch'
76 test_expect_success 'file becomes symlink' '
77 git checkout -f initial &&
78 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
79 git apply --index < patch
81 test_debug 'cat patch'
84 test_expect_success 'symlink becomes file' '
85 git checkout -f foo-symlinked-to-bar &&
86 git diff-tree -p HEAD foo-back-to-file > patch &&
87 git apply --index < patch
89 test_debug 'cat patch'
91 test_expect_success 'symlink becomes file, in reverse' '
92 git checkout -f foo-symlinked-to-bar &&
93 git diff-tree -p HEAD foo-back-to-file > patch &&
94 git checkout foo-back-to-file &&
95 git apply -R --index < 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