Merge branch 'sb/push-options-via-transport'
authorJunio C Hamano <gitster@pobox.com>
Wed, 15 Feb 2017 20:54:19 +0000 (12:54 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Feb 2017 20:54:19 +0000 (12:54 -0800)
The push-options given via the "--push-options" option were not
passed through to external remote helpers such as "smart HTTP" that
are invoked via the transport helper.

* sb/push-options-via-transport:
push options: pass push options to the transport helper

Documentation/gitremote-helpers.txt
t/t5545-push-options.sh
transport-helper.c
index 9e8681f9e1b554113e7d1881e214bc617af14109..23474b1eaba67a1c96cada7d3553396d21a5ab89 100644 (file)
@@ -462,6 +462,10 @@ set by Git if the remote helper has the 'option' capability.
 'option pushcert {'true'|'false'}::
        GPG sign pushes.
 
+'option push-option <string>::
+       Transmit <string> as a push option. As the a push option
+       must not contain LF or NUL characters, the string is not encoded.
+
 SEE ALSO
 --------
 linkgit:git-remote[1]
index ea813b9383de96a00b6d6745169ccffc4d45fecc..9a57a7d8f2319e48a267e4f2a605e420f779fd96 100755 (executable)
@@ -3,6 +3,8 @@
 test_description='pushing to a repository using push options'
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
 
 mk_repo_pair () {
        rm -rf workbench upstream &&
@@ -100,4 +102,17 @@ test_expect_success 'two push options work' '
        test_cmp expect upstream/.git/hooks/post-receive.push_options
 '
 
+test_expect_success 'push option denied properly by http remote helper' '\
+       mk_repo_pair &&
+       git -C upstream config receive.advertisePushOptions false &&
+       git -C upstream config http.receivepack true &&
+       cp -R upstream/.git "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git &&
+       git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
+       test_commit -C test_http_clone one &&
+       test_must_fail git -C test_http_clone push --push-option=asdf origin master &&
+       git -C test_http_clone push origin master
+'
+
+stop_httpd
+
 test_done
index 91aed35ebbc3cbb4fb9acbad55ab3de69e62d9f5..1258d6aedd26538f55c60495a61608236262cfc1 100644 (file)
@@ -826,6 +826,13 @@ static void set_common_push_options(struct transport *transport,
                if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "if-asked") != 0)
                        die("helper %s does not support --signed=if-asked", name);
        }
+
+       if (flags & TRANSPORT_PUSH_OPTIONS) {
+               struct string_list_item *item;
+               for_each_string_list_item(item, transport->push_options)
+                       if (set_helper_option(transport, "push-option", item->string) != 0)
+                               die("helper %s does not support 'push-option'", name);
+       }
 }
 
 static int push_refs_with_push(struct transport *transport,