Welcome to mirror list, hosted at ThFree Co, Russian Federation.

t5504-fetch-receive-strict.sh « t - git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 771a94b4b6c1ee3d55e8e441e053eaafe5e373aa (plain)
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
240
241
242
243
244
245
#!/bin/sh

test_description='fetch/receive strict mode'
. ./test-lib.sh

test_expect_success 'setup and inject "corrupt or missing" object' '
	echo hello >greetings &&
	git add greetings &&
	git commit -m greetings &&

	S=$(git rev-parse :greetings | sed -e "s|^..|&/|") &&
	X=$(echo bye | git hash-object -w --stdin | sed -e "s|^..|&/|") &&
	echo $S >S &&
	echo $X >X &&
	cp .git/objects/$S .git/objects/$S.back &&
	mv -f .git/objects/$X .git/objects/$S &&

	test_must_fail git fsck
'

test_expect_success 'fetch without strict' '
	rm -rf dst &&
	git init dst &&
	(
		cd dst &&
		git config fetch.fsckobjects false &&
		git config transfer.fsckobjects false &&
		test_must_fail git fetch ../.git master
	)
'

test_expect_success 'fetch with !fetch.fsckobjects' '
	rm -rf dst &&
	git init dst &&
	(
		cd dst &&
		git config fetch.fsckobjects false &&
		git config transfer.fsckobjects true &&
		test_must_fail git fetch ../.git master
	)
'

test_expect_success 'fetch with fetch.fsckobjects' '
	rm -rf dst &&
	git init dst &&
	(
		cd dst &&
		git config fetch.fsckobjects true &&
		git config transfer.fsckobjects false &&
		test_must_fail git fetch ../.git master
	)
'

test_expect_success 'fetch with transfer.fsckobjects' '
	rm -rf dst &&
	git init dst &&
	(
		cd dst &&
		git config transfer.fsckobjects true &&
		test_must_fail git fetch ../.git master
	)
'

cat >exp <<EOF
To dst
!	refs/heads/master:refs/heads/test	[remote rejected] (missing necessary objects)
EOF

test_expect_success 'push without strict' '
	rm -rf dst &&
	git init dst &&
	(
		cd dst &&
		git config fetch.fsckobjects false &&
		git config transfer.fsckobjects false
	) &&
	test_must_fail git push --porcelain dst master:refs/heads/test >act &&
	test_cmp exp act
'

test_expect_success 'push with !receive.fsckobjects' '
	rm -rf dst &&
	git init dst &&
	(
		cd dst &&
		git config receive.fsckobjects false &&
		git config transfer.fsckobjects true
	) &&
	test_must_fail git push --porcelain dst master:refs/heads/test >act &&
	test_cmp exp act
'

cat >exp <<EOF
To dst
!	refs/heads/master:refs/heads/test	[remote rejected] (unpacker error)
EOF

test_expect_success 'push with receive.fsckobjects' '
	rm -rf dst &&
	git init dst &&
	(
		cd dst &&
		git config receive.fsckobjects true &&
		git config transfer.fsckobjects false
	) &&
	test_must_fail git push --porcelain dst master:refs/heads/test >act &&
	test_cmp exp act
'

test_expect_success 'push with transfer.fsckobjects' '
	rm -rf dst &&
	git init dst &&
	(
		cd dst &&
		git config transfer.fsckobjects true
	) &&
	test_must_fail git push --porcelain dst master:refs/heads/test >act &&
	test_cmp exp act
'

test_expect_success 'repair the "corrupt or missing" object' '
	mv -f .git/objects/$(cat S) .git/objects/$(cat X) &&
	mv .git/objects/$(cat S).back .git/objects/$(cat S) &&
	rm -rf .git/objects/$(cat X) &&
	git fsck
'

cat >bogus-commit <<EOF
tree $EMPTY_TREE
author Bugs Bunny 1234567890 +0000
committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000

This commit object intentionally broken
EOF

test_expect_success 'push with receive.fsck.skipList' '
	commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
	git push . $commit:refs/heads/bogus &&
	rm -rf dst &&
	git init dst &&
	git --git-dir=dst/.git config receive.fsckObjects true &&
	test_must_fail git push --porcelain dst bogus &&
	echo $commit >dst/.git/SKIP &&

	# receive.fsck.* does not fall back on fsck.*
	git --git-dir=dst/.git config fsck.skipList SKIP &&
	test_must_fail git push --porcelain dst bogus &&

	git --git-dir=dst/.git config receive.fsck.skipList SKIP &&
	git push --porcelain dst bogus
'

test_expect_success 'fetch with fetch.fsck.skipList' '
	commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
	refspec=refs/heads/bogus:refs/heads/bogus &&
	git push . $commit:refs/heads/bogus &&
	rm -rf dst &&
	git init dst &&
	git --git-dir=dst/.git config fetch.fsckObjects true &&
	test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&
	git --git-dir=dst/.git config fetch.fsck.skipList /dev/null &&
	test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&
	echo $commit >dst/.git/SKIP &&

	# fetch.fsck.* does not fall back on fsck.*
	git --git-dir=dst/.git config fsck.skipList dst/.git/SKIP &&
	test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&

	git --git-dir=dst/.git config fetch.fsck.skipList dst/.git/SKIP &&
	git --git-dir=dst/.git fetch "file://$(pwd)" $refspec
'


test_expect_success 'push with receive.fsck.missingEmail=warn' '
	commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
	git push . $commit:refs/heads/bogus &&
	rm -rf dst &&
	git init dst &&
	git --git-dir=dst/.git config receive.fsckobjects true &&
	test_must_fail git push --porcelain dst bogus &&

	# receive.fsck.<msg-id> does not fall back on fsck.<msg-id>
	git --git-dir=dst/.git config fsck.missingEmail warn &&
	test_must_fail git push --porcelain dst bogus &&

	git --git-dir=dst/.git config \
		receive.fsck.missingEmail warn &&
	git push --porcelain dst bogus >act 2>&1 &&
	grep "missingEmail" act &&
	git --git-dir=dst/.git branch -D bogus &&
	git --git-dir=dst/.git config --add \
		receive.fsck.missingEmail ignore &&
	git push --porcelain dst bogus >act 2>&1 &&
	! grep "missingEmail" act
'

test_expect_success 'fetch with fetch.fsck.missingEmail=warn' '
	commit="$(git hash-object -t commit -w --stdin <bogus-commit)" &&
	refspec=refs/heads/bogus:refs/heads/bogus &&
	git push . $commit:refs/heads/bogus &&
	rm -rf dst &&
	git init dst &&
	git --git-dir=dst/.git config fetch.fsckobjects true &&
	test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&

	# fetch.fsck.<msg-id> does not fall back on fsck.<msg-id>
	git --git-dir=dst/.git config fsck.missingEmail warn &&
	test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" $refspec &&

	git --git-dir=dst/.git config \
		fetch.fsck.missingEmail warn &&
	git --git-dir=dst/.git fetch "file://$(pwd)" $refspec >act 2>&1 &&
	grep "missingEmail" act &&
	rm -rf dst &&
	git init dst &&
	git --git-dir=dst/.git config fetch.fsckobjects true &&
	git --git-dir=dst/.git config \
		fetch.fsck.missingEmail ignore &&
	git --git-dir=dst/.git fetch "file://$(pwd)" $refspec >act 2>&1 &&
	! grep "missingEmail" act
'

test_expect_success \
	'receive.fsck.unterminatedHeader=warn triggers error' '
	rm -rf dst &&
	git init dst &&
	git --git-dir=dst/.git config receive.fsckobjects true &&
	git --git-dir=dst/.git config \
		receive.fsck.unterminatedheader warn &&
	test_must_fail git push --porcelain dst HEAD >act 2>&1 &&
	grep "Cannot demote unterminatedheader" act
'

test_expect_success \
	'fetch.fsck.unterminatedHeader=warn triggers error' '
	rm -rf dst &&
	git init dst &&
	git --git-dir=dst/.git config fetch.fsckobjects true &&
	git --git-dir=dst/.git config \
		fetch.fsck.unterminatedheader warn &&
	test_must_fail git --git-dir=dst/.git fetch "file://$(pwd)" HEAD &&
	grep "Cannot demote unterminatedheader" act
'

test_done