test-lib: fix broken printf
[git/spearce.git] / t / t4114-apply-typechange.sh
blob55334927abb33864a55f8ff49fd0c0c94a3c1769
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 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 &&
28 rm -f foo &&
29 git update-index --remove foo &&
30 mkdir foo &&
31 echo "if only I knew" > foo/baz &&
32 git update-index --add foo/baz &&
33 git commit -m "foo becomes a directory" &&
34 git branch "foo-becomes-a-directory" &&
35 echo "hello world" > foo/baz &&
36 git update-index foo/baz &&
37 git commit -m "foo/baz is the original foo" &&
38 git branch foo-baz-renamed-from-foo
41 test_expect_success 'file renamed from foo to foo/baz' '
42 git checkout -f initial &&
43 git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
44 git apply --index < patch
46 test_debug 'cat patch'
49 test_expect_success 'file renamed from foo/baz to foo' '
50 git checkout -f foo-baz-renamed-from-foo &&
51 git diff-tree -M -p HEAD initial > patch &&
52 git apply --index < patch
54 test_debug 'cat patch'
57 test_expect_success 'directory becomes file' '
58 git checkout -f foo-becomes-a-directory &&
59 git diff-tree -p HEAD initial > patch &&
60 git apply --index < patch
62 test_debug 'cat patch'
65 test_expect_success 'file becomes directory' '
66 git checkout -f initial &&
67 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
68 git apply --index < patch
70 test_debug 'cat patch'
73 test_expect_success 'file becomes symlink' '
74 git checkout -f initial &&
75 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
76 git apply --index < patch
78 test_debug 'cat patch'
81 test_expect_success 'symlink becomes file' '
82 git checkout -f foo-symlinked-to-bar &&
83 git diff-tree -p HEAD foo-back-to-file > patch &&
84 git apply --index < patch
86 test_debug 'cat patch'
89 test_expect_success 'symlink becomes directory' '
90 git checkout -f foo-symlinked-to-bar &&
91 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
92 git apply --index < patch
94 test_debug 'cat patch'
97 test_expect_success 'directory becomes symlink' '
98 git checkout -f foo-becomes-a-directory &&
99 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
100 git apply --index < patch
102 test_debug 'cat patch'
105 test_done