git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
c8a81f180fa422a725a8103cd22b01cd0e13578a blob 5690 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
 
#!/bin/sh

test_description='read-tree -m -u checks working tree files'

. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh

# two-tree test

test_expect_success 'two-way setup' '

	mkdir subdir &&
	echo >file1 file one &&
	echo >file2 file two &&
	echo >subdir/file1 file one in subdirectory &&
	echo >subdir/file2 file two in subdirectory &&
	git update-index --add file1 file2 subdir/file1 subdir/file2 &&
	git commit -m initial &&

	git branch side &&
	git tag -f branch-point &&

	echo file2 is not tracked on the main branch anymore &&
	rm -f file2 subdir/file2 &&
	git update-index --remove file2 subdir/file2 &&
	git commit -a -m "main removes file2 and subdir/file2"
'

test_expect_success 'two-way not clobbering' '

	echo >file2 main creates untracked file2 &&
	echo >subdir/file2 main creates untracked subdir/file2 &&
	if err=$(read_tree_u_must_succeed -m -u main side 2>&1)
	then
		echo should have complained
		false
	else
		echo "happy to see $err"
	fi
'

echo file2 >.gitignore

test_expect_success 'two-way with incorrect --exclude-per-directory (1)' '

	if err=$(read_tree_u_must_succeed -m --exclude-per-directory=.gitignore main side 2>&1)
	then
		echo should have complained
		false
	else
		echo "happy to see $err"
	fi
'

test_expect_success 'two-way with incorrect --exclude-per-directory (2)' '

	if err=$(read_tree_u_must_succeed -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore main side 2>&1)
	then
		echo should have complained
		false
	else
		echo "happy to see $err"
	fi
'

test_expect_success 'two-way clobbering a ignored file' '

	read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore main side
'

rm -f .gitignore

# three-tree test

test_expect_success 'three-way not complaining on an untracked path in both' '

	rm -f file2 subdir/file2 &&
	git checkout side &&
	echo >file3 file three &&
	echo >subdir/file3 file three &&
	git update-index --add file3 subdir/file3 &&
	git commit -a -m "side adds file3 and removes file2" &&

	git checkout main &&
	echo >file2 file two is untracked on the main side &&
	echo >subdir/file2 file two is untracked on the main side &&

	read_tree_u_must_succeed -m -u branch-point main side
'

test_expect_success 'three-way not clobbering a working tree file' '

	git reset --hard &&
	rm -f file2 subdir/file2 file3 subdir/file3 &&
	git checkout main &&
	echo >file3 file three created in main, untracked &&
	echo >subdir/file3 file three created in main, untracked &&
	if err=$(read_tree_u_must_succeed -m -u branch-point main side 2>&1)
	then
		echo should have complained
		false
	else
		echo "happy to see $err"
	fi
'

echo >.gitignore file3

test_expect_success 'three-way not complaining on an untracked file' '

	git reset --hard &&
	rm -f file2 subdir/file2 file3 subdir/file3 &&
	git checkout main &&
	echo >file3 file three created in main, untracked &&
	echo >subdir/file3 file three created in main, untracked &&

	read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore branch-point main side
'

test_expect_success '3-way not overwriting local changes (setup)' '

	git reset --hard &&
	git checkout -b side-a branch-point &&
	echo >>file1 "new line to be kept in the merge result" &&
	git commit -a -m "side-a changes file1" &&
	git checkout -b side-b branch-point &&
	echo >>file2 "new line to be kept in the merge result" &&
	git commit -a -m "side-b changes file2" &&
	git checkout side-a

'

test_expect_success '3-way not overwriting local changes (our side)' '

	# At this point, file1 from side-a should be kept as side-b
	# did not touch it.

	git reset --hard &&

	echo >>file1 "local changes" &&
	read_tree_u_must_succeed -m -u branch-point side-a side-b &&
	grep "new line to be kept" file1 &&
	grep "local changes" file1

'

test_expect_success '3-way not overwriting local changes (their side)' '

	# At this point, file2 from side-b should be taken as side-a
	# did not touch it.

	git reset --hard &&

	echo >>file2 "local changes" &&
	read_tree_u_must_fail -m -u branch-point side-a side-b &&
	! grep "new line to be kept" file2 &&
	grep "local changes" file2

'

test_expect_success 'funny symlink in work tree' '

	git reset --hard &&
	git checkout -b sym-b side-b &&
	mkdir -p a &&
	>a/b &&
	git add a/b &&
	git commit -m "side adds a/b" &&

	rm -fr a &&
	git checkout -b sym-a side-a &&
	mkdir -p a &&
	test_ln_s_add ../b a/b &&
	git commit -m "we add a/b" &&

	read_tree_u_must_succeed -m -u sym-a sym-a sym-b

'

test_expect_success SANITY 'funny symlink in work tree, un-unlink-able' '

	test_when_finished "chmod u+w a 2>/dev/null; rm -fr a b" &&

	rm -fr a b &&
	git reset --hard &&

	git checkout sym-a &&
	chmod a-w a &&
	test_must_fail git read-tree -m -u sym-a sym-a sym-b

'

test_expect_success 'D/F setup' '

	git reset --hard &&

	git checkout side-a &&
	rm -f subdir/file2 &&
	mkdir subdir/file2 &&
	echo qfwfq >subdir/file2/another &&
	git add subdir/file2/another &&
	test_tick &&
	git commit -m "side-a changes file2 to directory"

'

test_expect_success 'D/F' '

	git checkout side-b &&
	read_tree_u_must_succeed -m -u branch-point side-b side-a &&
	git ls-files -u >actual &&
	(
		a=$(git rev-parse branch-point:subdir/file2) &&
		b=$(git rev-parse side-a:subdir/file2/another) &&
		echo "100644 $a 1	subdir/file2" &&
		echo "100644 $a 2	subdir/file2" &&
		echo "100644 $b 3	subdir/file2/another"
	) >expect &&
	test_cmp expect actual

'

test_expect_success 'D/F resolve' '

	git reset --hard &&
	git checkout side-b &&
	git merge-resolve branch-point -- side-b side-a

'

test_expect_success 'D/F recursive' '

	git reset --hard &&
	git checkout side-b &&
	git merge-recursive branch-point -- side-b side-a

'

test_done
debug log:

solving c8a81f180f ...
found c8a81f180f in https://public-inbox.org/git/830130fa9fff3bf39e9f5b0360160e9ff787deec.1605221038.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/b8fa037791683b50c3efb01aa6ac0d3f7b888a2b.1605629548.git.gitgitgadget@gmail.com/
found 181956b241 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 181956b24137f2de91117d344b61c28214000a9f	t/t1004-read-tree-m-u-wf.sh

applying [1/2] https://public-inbox.org/git/830130fa9fff3bf39e9f5b0360160e9ff787deec.1605221038.git.gitgitgadget@gmail.com/
diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh
index 181956b241..c8a81f180f 100755

Checking patch t/t1004-read-tree-m-u-wf.sh...
Applied patch t/t1004-read-tree-m-u-wf.sh cleanly.

skipping https://public-inbox.org/git/b8fa037791683b50c3efb01aa6ac0d3f7b888a2b.1605629548.git.gitgitgadget@gmail.com/ for c8a81f180f
index at:
100755 c8a81f180fa422a725a8103cd22b01cd0e13578a	t/t1004-read-tree-m-u-wf.sh

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).