]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4114-apply-typechange.sh
The sixth batch
[thirdparty/git.git] / t / t4114-apply-typechange.sh
CommitLineData
8641fb24
EW
1#!/bin/sh
2#
3# Copyright (c) 2006 Eric Wong
4#
5
5be60078 6test_description='git apply should not get confused with type changes.
8641fb24
EW
7
8'
9
10. ./test-lib.sh
11
622f98e2 12test_expect_success 'setup repository and commits' '
8641fb24
EW
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 &&
622f98e2 19 test_ln_s_add bar foo &&
8641fb24
EW
20 git commit -m "foo symlinked to bar" &&
21 git branch foo-symlinked-to-bar &&
622f98e2 22 git rm -f foo &&
8641fb24 23 echo "how far is the sun?" > foo &&
622f98e2 24 git update-index --add foo &&
8641fb24
EW
25 git commit -m "foo back to file" &&
26 git branch foo-back-to-file &&
b67b9612
JH
27 printf "\0" > foo &&
28 git update-index foo &&
29 git commit -m "foo becomes binary" &&
30 git branch foo-becomes-binary &&
8641fb24
EW
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
42 '
43
622f98e2 44test_expect_success 'file renamed from foo to foo/baz' '
8641fb24
EW
45 git checkout -f initial &&
46 git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
47 git apply --index < patch
48 '
49test_debug 'cat patch'
50
51
622f98e2 52test_expect_success 'file renamed from foo/baz to foo' '
8641fb24
EW
53 git checkout -f foo-baz-renamed-from-foo &&
54 git diff-tree -M -p HEAD initial > patch &&
55 git apply --index < patch
56 '
57test_debug 'cat patch'
58
59
622f98e2 60test_expect_success 'directory becomes file' '
8641fb24
EW
61 git checkout -f foo-becomes-a-directory &&
62 git diff-tree -p HEAD initial > patch &&
63 git apply --index < patch
64 '
65test_debug 'cat patch'
66
67
622f98e2 68test_expect_success 'file becomes directory' '
8641fb24
EW
69 git checkout -f initial &&
70 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
71 git apply --index < patch
72 '
73test_debug 'cat patch'
74
75
622f98e2 76test_expect_success 'file becomes symlink' '
8641fb24
EW
77 git checkout -f initial &&
78 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
79 git apply --index < patch
80 '
81test_debug 'cat patch'
82
83
622f98e2 84test_expect_success 'symlink becomes file' '
8641fb24
EW
85 git checkout -f foo-symlinked-to-bar &&
86 git diff-tree -p HEAD foo-back-to-file > patch &&
87 git apply --index < patch
88 '
89test_debug 'cat patch'
90
622f98e2 91test_expect_success 'binary file becomes symlink' '
b67b9612
JH
92 git checkout -f foo-becomes-binary &&
93 git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch &&
94 git apply --index < patch
95 '
96test_debug 'cat patch'
97
622f98e2 98test_expect_success 'symlink becomes binary file' '
b67b9612
JH
99 git checkout -f foo-symlinked-to-bar &&
100 git diff-tree -p --binary HEAD foo-becomes-binary > patch &&
101 git apply --index < patch
102 '
103test_debug 'cat patch'
104
8641fb24 105
622f98e2 106test_expect_success 'symlink becomes directory' '
8641fb24
EW
107 git checkout -f foo-symlinked-to-bar &&
108 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
109 git apply --index < patch
110 '
111test_debug 'cat patch'
112
113
622f98e2 114test_expect_success 'directory becomes symlink' '
8641fb24
EW
115 git checkout -f foo-becomes-a-directory &&
116 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
117 git apply --index < patch
118 '
119test_debug 'cat patch'
120
121
122test_done