Skip to content

Commit ca3c2b8

Browse files
committed
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
2 parents 3f4ccb5 + 438fc68 commit ca3c2b8

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

Documentation/gitremote-helpers.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ set by Git if the remote helper has the 'option' capability.
462462
'option pushcert {'true'|'false'}::
463463
GPG sign pushes.
464464

465+
'option push-option <string>::
466+
Transmit <string> as a push option. As the a push option
467+
must not contain LF or NUL characters, the string is not encoded.
468+
465469
SEE ALSO
466470
--------
467471
linkgit:git-remote[1]

t/t5545-push-options.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
test_description='pushing to a repository using push options'
44

55
. ./test-lib.sh
6+
. "$TEST_DIRECTORY"/lib-httpd.sh
7+
start_httpd
68

79
mk_repo_pair () {
810
rm -rf workbench upstream &&
@@ -100,4 +102,17 @@ test_expect_success 'two push options work' '
100102
test_cmp expect upstream/.git/hooks/post-receive.push_options
101103
'
102104

105+
test_expect_success 'push option denied properly by http remote helper' '\
106+
mk_repo_pair &&
107+
git -C upstream config receive.advertisePushOptions false &&
108+
git -C upstream config http.receivepack true &&
109+
cp -R upstream/.git "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git &&
110+
git clone "$HTTPD_URL"/smart/upstream test_http_clone &&
111+
test_commit -C test_http_clone one &&
112+
test_must_fail git -C test_http_clone push --push-option=asdf origin master &&
113+
git -C test_http_clone push origin master
114+
'
115+
116+
stop_httpd
117+
103118
test_done

transport-helper.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,13 @@ static void set_common_push_options(struct transport *transport,
826826
if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "if-asked") != 0)
827827
die("helper %s does not support --signed=if-asked", name);
828828
}
829+
830+
if (flags & TRANSPORT_PUSH_OPTIONS) {
831+
struct string_list_item *item;
832+
for_each_string_list_item(item, transport->push_options)
833+
if (set_helper_option(transport, "push-option", item->string) != 0)
834+
die("helper %s does not support 'push-option'", name);
835+
}
829836
}
830837

831838
static int push_refs_with_push(struct transport *transport,

0 commit comments

Comments
 (0)