@@ -657,7 +657,7 @@ static int set_transport_custom_headers(git_transport *t, const git_strarray *cu
657657 return t -> set_custom_headers (t , custom_headers );
658658}
659659
660- int git_remote_connect (git_remote * remote , git_direction direction , const git_remote_callbacks * callbacks , const git_proxy_options * proxy , const git_strarray * custom_headers )
660+ int git_remote__connect (git_remote * remote , git_direction direction , const git_remote_callbacks * callbacks , const git_remote_connection_opts * conn )
661661{
662662 git_transport * t ;
663663 const char * url ;
@@ -676,8 +676,8 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
676676 payload = callbacks -> payload ;
677677 }
678678
679- if (proxy )
680- GITERR_CHECK_VERSION (proxy , GIT_PROXY_OPTIONS_VERSION , "git_proxy_options" );
679+ if (conn -> proxy )
680+ GITERR_CHECK_VERSION (conn -> proxy , GIT_PROXY_OPTIONS_VERSION , "git_proxy_options" );
681681
682682 t = remote -> transport ;
683683
@@ -701,11 +701,11 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
701701 if (!t && (error = git_transport_new (& t , remote , url )) < 0 )
702702 return error ;
703703
704- if ((error = set_transport_custom_headers (t , custom_headers )) != 0 )
704+ if ((error = set_transport_custom_headers (t , conn -> custom_headers )) != 0 )
705705 goto on_error ;
706706
707707 if ((error = set_transport_callbacks (t , callbacks )) < 0 ||
708- (error = t -> connect (t , url , credentials , payload , proxy , direction , flags )) != 0 )
708+ (error = t -> connect (t , url , credentials , payload , conn -> proxy , direction , flags )) != 0 )
709709 goto on_error ;
710710
711711 remote -> transport = t ;
@@ -721,6 +721,16 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re
721721 return error ;
722722}
723723
724+ int git_remote_connect (git_remote * remote , git_direction direction , const git_remote_callbacks * callbacks , const git_proxy_options * proxy , const git_strarray * custom_headers )
725+ {
726+ git_remote_connection_opts conn ;
727+
728+ conn .proxy = proxy ;
729+ conn .custom_headers = custom_headers ;
730+
731+ return git_remote__connect (remote , direction , callbacks , & conn );
732+ }
733+
724734int git_remote_ls (const git_remote_head * * * out , size_t * size , git_remote * remote )
725735{
726736 assert (remote );
@@ -949,21 +959,20 @@ int git_remote_fetch(
949959 bool prune = false;
950960 git_buf reflog_msg_buf = GIT_BUF_INIT ;
951961 const git_remote_callbacks * cbs = NULL ;
952- const git_strarray * custom_headers = NULL ;
953- const git_proxy_options * proxy = NULL ;
962+ git_remote_connection_opts conn = GIT_REMOTE_CONNECTION_OPTIONS_INIT ;
954963
955964 if (opts ) {
956965 GITERR_CHECK_VERSION (& opts -> callbacks , GIT_REMOTE_CALLBACKS_VERSION , "git_remote_callbacks" );
957966 cbs = & opts -> callbacks ;
958- custom_headers = & opts -> custom_headers ;
967+ conn . custom_headers = & opts -> custom_headers ;
959968 update_fetchhead = opts -> update_fetchhead ;
960969 tagopt = opts -> download_tags ;
961970 GITERR_CHECK_VERSION (& opts -> proxy_opts , GIT_PROXY_OPTIONS_VERSION , "git_proxy_options" );
962- proxy = & opts -> proxy_opts ;
971+ conn . proxy = & opts -> proxy_opts ;
963972 }
964973
965974 /* Connect and download everything */
966- if ((error = git_remote_connect (remote , GIT_DIRECTION_FETCH , cbs , proxy , custom_headers )) != 0 )
975+ if ((error = git_remote__connect (remote , GIT_DIRECTION_FETCH , cbs , & conn )) != 0 )
967976 return error ;
968977
969978 error = git_remote_download (remote , refspecs , opts );
@@ -2373,8 +2382,7 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
23732382 git_push * push ;
23742383 git_refspec * spec ;
23752384 const git_remote_callbacks * cbs = NULL ;
2376- const git_strarray * custom_headers = NULL ;
2377- const git_proxy_options * proxy = NULL ;
2385+ git_remote_connection_opts conn = GIT_REMOTE_CONNECTION_OPTIONS_INIT ;
23782386
23792387 assert (remote );
23802388
@@ -2385,12 +2393,12 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
23852393
23862394 if (opts ) {
23872395 cbs = & opts -> callbacks ;
2388- custom_headers = & opts -> custom_headers ;
2389- proxy = & opts -> proxy_opts ;
2396+ conn . custom_headers = & opts -> custom_headers ;
2397+ conn . proxy = & opts -> proxy_opts ;
23902398 }
23912399
23922400 if (!git_remote_connected (remote ) &&
2393- (error = git_remote_connect (remote , GIT_DIRECTION_PUSH , cbs , proxy , custom_headers )) < 0 )
2401+ (error = git_remote__connect (remote , GIT_DIRECTION_PUSH , cbs , & conn )) < 0 )
23942402 goto cleanup ;
23952403
23962404 free_refspecs (& remote -> active_refspecs );
0 commit comments