summaryrefslogtreecommitdiff
path: root/t/t5545-push-options.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-02-19 19:50:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-02-20 19:27:06 (GMT)
commit90dce21eb0fcf28096e661a3dd3b4e93fa0bccb5 (patch)
treeceb454eaaec086ea142c95d09078a25751b73e33 /t/t5545-push-options.sh
parent6cdffd06d6ce1e997963790f9206fc981715fbbb (diff)
downloadgit-90dce21eb0fcf28096e661a3dd3b4e93fa0bccb5.zip
git-90dce21eb0fcf28096e661a3dd3b4e93fa0bccb5.tar.gz
git-90dce21eb0fcf28096e661a3dd3b4e93fa0bccb5.tar.bz2
remote-curl: unquote incoming push-options
The transport-helper protocol c-style quotes the value of any options passed to the helper via the "option <key> <value>" directive. However, remote-curl doesn't actually unquote the push-option values, meaning that we will send the quoted version to the other side (whereas git-over-ssh would send the raw value). The pack-protocol.txt documentation defines the push-options as a series of VCHARs, which excludes most characters that would need quoting. But: 1. You can still see the bug with a valid push-option that starts with a double-quote (since that triggers quoting). 2. We do currently handle any non-NUL characters correctly in git-over-ssh. So even though the spec does not say that we need to handle most quoted characters, it's nice if our behavior is consistent between protocols. There are two new tests: the "direct" one shows that this already works in the non-http case, and the http one covers this bugfix. Reported-by: Jon Simons <jon@jonsimons.org> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5545-push-options.sh')
-rwxr-xr-xt/t5545-push-options.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t5545-push-options.sh b/t/t5545-push-options.sh
index c64dee2..b47a958 100755
--- a/t/t5545-push-options.sh
+++ b/t/t5545-push-options.sh
@@ -217,6 +217,15 @@ test_expect_success 'invalid push option in config' '
test_refs master HEAD@{1}
'
+test_expect_success 'push options keep quoted characters intact (direct)' '
+ mk_repo_pair &&
+ git -C upstream config receive.advertisePushOptions true &&
+ test_commit -C workbench one &&
+ git -C workbench push --push-option="\"embedded quotes\"" up master &&
+ echo "\"embedded quotes\"" >expect &&
+ test_cmp expect upstream/.git/hooks/pre-receive.push_options
+'
+
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
@@ -260,6 +269,15 @@ test_expect_success 'push options work properly across http' '
test_cmp expect actual
'
+test_expect_success 'push options keep quoted characters intact (http)' '
+ mk_http_pair true &&
+
+ test_commit -C test_http_clone one &&
+ git -C test_http_clone push --push-option="\"embedded quotes\"" origin master &&
+ echo "\"embedded quotes\"" >expect &&
+ test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options
+'
+
stop_httpd
test_done