@@ -217,31 +217,40 @@ test_expect_success 'invalid push option in config' '
217217 test_refs master HEAD@{1}
218218'
219219
220+ test_expect_success ' push options keep quoted characters intact (direct)' '
221+ mk_repo_pair &&
222+ git -C upstream config receive.advertisePushOptions true &&
223+ test_commit -C workbench one &&
224+ git -C workbench push --push-option="\"embedded quotes\"" up master &&
225+ echo "\"embedded quotes\"" >expect &&
226+ test_cmp expect upstream/.git/hooks/pre-receive.push_options
227+ '
228+
220229. " $TEST_DIRECTORY " /lib-httpd.sh
221230start_httpd
222231
223- test_expect_success ' push option denied properly by http server' '
232+ # set up http repository for fetching/pushing, with push options config
233+ # bool set to $1
234+ mk_http_pair () {
224235 test_when_finished " rm -rf test_http_clone" &&
225- test_when_finished " rm -rf \ "$HTTPD_DOCUMENT_ROOT_PATH\ "/upstream.git" &&
236+ test_when_finished ' rm -rf "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git' &&
226237 mk_repo_pair &&
227- git -C upstream config receive.advertisePushOptions false &&
238+ git -C upstream config receive.advertisePushOptions " $1 " &&
228239 git -C upstream config http.receivepack true &&
229240 cp -R upstream/.git " $HTTPD_DOCUMENT_ROOT_PATH " /upstream.git &&
230- git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
241+ git clone " $HTTPD_URL " /smart/upstream test_http_clone
242+ }
243+
244+ test_expect_success ' push option denied properly by http server' '
245+ mk_http_pair false &&
231246 test_commit -C test_http_clone one &&
232247 test_must_fail git -C test_http_clone push --push-option=asdf origin master 2>actual &&
233248 test_i18ngrep "the receiving end does not support push options" actual &&
234249 git -C test_http_clone push origin master
235250'
236251
237252test_expect_success ' push options work properly across http' '
238- test_when_finished "rm -rf test_http_clone" &&
239- test_when_finished "rm -rf \"$HTTPD_DOCUMENT_ROOT_PATH\"/upstream.git" &&
240- mk_repo_pair &&
241- git -C upstream config receive.advertisePushOptions true &&
242- git -C upstream config http.receivepack true &&
243- cp -R upstream/.git "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git &&
244- git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
253+ mk_http_pair true &&
245254
246255 test_commit -C test_http_clone one &&
247256 git -C test_http_clone push origin master &&
@@ -260,6 +269,15 @@ test_expect_success 'push options work properly across http' '
260269 test_cmp expect actual
261270'
262271
272+ test_expect_success ' push options keep quoted characters intact (http)' '
273+ mk_http_pair true &&
274+
275+ test_commit -C test_http_clone one &&
276+ git -C test_http_clone push --push-option="\"embedded quotes\"" origin master &&
277+ echo "\"embedded quotes\"" >expect &&
278+ test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options
279+ '
280+
263281stop_httpd
264282
265283test_done
0 commit comments