Merge branch 'sb/push-options-via-transport'

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
This commit is contained in:
Junio C Hamano 2017-02-15 12:54:19 -08:00
Родитель 3f4ccb5a57 438fc68462
Коммит ca3c2b85d1
3 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -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]

Просмотреть файл

@ -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

Просмотреть файл

@ -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,