]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4114-apply-typechange.sh
The third 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
3e3b9321 10TEST_PASSES_SANITIZE_LEAK=true
8641fb24
EW
11. ./test-lib.sh
12
622f98e2 13test_expect_success 'setup repository and commits' '
8641fb24
EW
14 echo "hello world" > foo &&
15 echo "hi planet" > bar &&
16 git update-index --add foo bar &&
17 git commit -m initial &&
18 git branch initial &&
19 rm -f foo &&
622f98e2 20 test_ln_s_add bar foo &&
8641fb24
EW
21 git commit -m "foo symlinked to bar" &&
22 git branch foo-symlinked-to-bar &&
622f98e2 23 git rm -f foo &&
8641fb24 24 echo "how far is the sun?" > foo &&
622f98e2 25 git update-index --add foo &&
8641fb24
EW
26 git commit -m "foo back to file" &&
27 git branch foo-back-to-file &&
b67b9612
JH
28 printf "\0" > foo &&
29 git update-index foo &&
30 git commit -m "foo becomes binary" &&
31 git branch foo-becomes-binary &&
8641fb24
EW
32 rm -f foo &&
33 git update-index --remove foo &&
34 mkdir foo &&
35 echo "if only I knew" > foo/baz &&
36 git update-index --add foo/baz &&
37 git commit -m "foo becomes a directory" &&
38 git branch "foo-becomes-a-directory" &&
39 echo "hello world" > foo/baz &&
40 git update-index foo/baz &&
41 git commit -m "foo/baz is the original foo" &&
42 git branch foo-baz-renamed-from-foo
43 '
44
622f98e2 45test_expect_success 'file renamed from foo to foo/baz' '
8641fb24
EW
46 git checkout -f initial &&
47 git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
48 git apply --index < patch
49 '
50test_debug 'cat patch'
51
52
622f98e2 53test_expect_success 'file renamed from foo/baz to foo' '
8641fb24
EW
54 git checkout -f foo-baz-renamed-from-foo &&
55 git diff-tree -M -p HEAD initial > patch &&
56 git apply --index < patch
57 '
58test_debug 'cat patch'
59
60
622f98e2 61test_expect_success 'directory becomes file' '
8641fb24
EW
62 git checkout -f foo-becomes-a-directory &&
63 git diff-tree -p HEAD initial > patch &&
64 git apply --index < patch
65 '
66test_debug 'cat patch'
67
68
622f98e2 69test_expect_success 'file becomes directory' '
8641fb24
EW
70 git checkout -f initial &&
71 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
72 git apply --index < patch
73 '
74test_debug 'cat patch'
75
76
622f98e2 77test_expect_success 'file becomes symlink' '
8641fb24
EW
78 git checkout -f initial &&
79 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
80 git apply --index < patch
81 '
82test_debug 'cat patch'
83
84
622f98e2 85test_expect_success 'symlink becomes file' '
8641fb24
EW
86 git checkout -f foo-symlinked-to-bar &&
87 git diff-tree -p HEAD foo-back-to-file > patch &&
88 git apply --index < patch
89 '
90test_debug 'cat patch'
91
b0f266de
JT
92test_expect_success 'symlink becomes file, in reverse' '
93 git checkout -f foo-symlinked-to-bar &&
94 git diff-tree -p HEAD foo-back-to-file > patch &&
95 git checkout foo-back-to-file &&
96 git apply -R --index < patch
97 '
98
622f98e2 99test_expect_success 'binary file becomes symlink' '
b67b9612
JH
100 git checkout -f foo-becomes-binary &&
101 git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch &&
102 git apply --index < patch
103 '
104test_debug 'cat patch'
105
622f98e2 106test_expect_success 'symlink becomes binary file' '
b67b9612
JH
107 git checkout -f foo-symlinked-to-bar &&
108 git diff-tree -p --binary HEAD foo-becomes-binary > patch &&
109 git apply --index < patch
110 '
111test_debug 'cat patch'
112
8641fb24 113
622f98e2 114test_expect_success 'symlink becomes directory' '
8641fb24
EW
115 git checkout -f foo-symlinked-to-bar &&
116 git diff-tree -p HEAD foo-becomes-a-directory > patch &&
117 git apply --index < patch
118 '
119test_debug 'cat patch'
120
121
622f98e2 122test_expect_success 'directory becomes symlink' '
8641fb24
EW
123 git checkout -f foo-becomes-a-directory &&
124 git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
125 git apply --index < patch
126 '
127test_debug 'cat patch'
128
129
130test_done