Merge branch 'master' of git://repo.or.cz/alt-git
[4msysgit-hv.git] / t / t4114-apply-typechange.sh
blob33c71ad38d78eea6b148dd6303c59de274086a8d
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 rm -f foo &&
34 git update-index --remove foo &&
35 mkdir foo &&
36 echo "if only I knew" > foo/baz &&
37 git update-index --add foo/baz &&
38 git commit -m "foo becomes a directory" &&
39 git branch "foo-becomes-a-directory" &&
40 echo "hello world" > foo/baz &&
41 git update-index foo/baz &&
42 git commit -m "foo/baz is the original foo" &&
43 git branch foo-baz-renamed-from-foo
46 test_expect_success 'file renamed from foo to foo/baz' '
47 git checkout -f initial &&
48 git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
49 git apply --index < patch
51 test_debug 'cat patch'
54 test_expect_success 'file renamed from foo/baz to foo' '
55 git checkout -f foo-baz-renamed-from-foo &&
56 git diff-tree -M -p HEAD initial > patch &&
57 git apply --index < patch
59 test_debug 'cat patch'
62 test_expect_success 'directory becomes file' '
63 git checkout -f foo-becomes-a-directory &&
64 git diff-tree -p HEAD initial > patch &&
65 git apply --index < patch
67 test_debug 'cat patch'
70 test_expect_success 'file becomes directory' '
71 git checkout -f initial &&
72 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
73 git apply --index < patch
75 test_debug 'cat patch'
78 test_expect_success 'file becomes symlink' '
79 git checkout -f initial &&
80 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
81 git apply --index < patch
83 test_debug 'cat patch'
86 test_expect_success 'symlink becomes file' '
87 git checkout -f foo-symlinked-to-bar &&
88 git diff-tree -p HEAD foo-back-to-file > patch &&
89 git apply --index < patch
91 test_debug 'cat patch'
94 test_expect_success 'symlink becomes directory' '
95 git checkout -f foo-symlinked-to-bar &&
96 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
97 git apply --index < patch
99 test_debug 'cat patch'
102 test_expect_success 'directory becomes symlink' '
103 git checkout -f foo-becomes-a-directory &&
104 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
105 git apply --index < patch
107 test_debug 'cat patch'
110 test_done