66static git_repository * repo ;
77static git_net_url url = GIT_NET_URL_INIT ;
88
9- static int orig_proxies_need_reset = 0 ;
109static char * orig_http_proxy = NULL ;
1110static char * orig_https_proxy = NULL ;
1211static char * orig_no_proxy = NULL ;
@@ -21,20 +20,25 @@ void test_remote_httpproxy__initialize(void)
2120
2221 git_remote_free (remote );
2322
24- orig_proxies_need_reset = 0 ;
23+ /* Clear everything for a fresh start */
24+ orig_http_proxy = cl_getenv ("HTTP_PROXY" );
25+ orig_https_proxy = cl_getenv ("HTTPS_PROXY" );
26+ orig_no_proxy = cl_getenv ("NO_PROXY" );
27+
28+ cl_setenv ("HTTP_PROXY" , NULL );
29+ cl_setenv ("HTTPS_PROXY" , NULL );
30+ cl_setenv ("NO_PROXY" , NULL );
2531}
2632
2733void test_remote_httpproxy__cleanup (void )
2834{
29- if (orig_proxies_need_reset ) {
30- cl_setenv ("HTTP_PROXY" , orig_http_proxy );
31- cl_setenv ("HTTPS_PROXY" , orig_https_proxy );
32- cl_setenv ("NO_PROXY" , orig_no_proxy );
33-
34- git__free (orig_http_proxy );
35- git__free (orig_https_proxy );
36- git__free (orig_no_proxy );
37- }
35+ cl_setenv ("HTTP_PROXY" , orig_http_proxy );
36+ cl_setenv ("HTTPS_PROXY" , orig_https_proxy );
37+ cl_setenv ("NO_PROXY" , orig_no_proxy );
38+
39+ git__free (orig_http_proxy );
40+ git__free (orig_https_proxy );
41+ git__free (orig_no_proxy );
3842
3943 git_net_url_dispose (& url );
4044 cl_git_sandbox_cleanup ();
@@ -145,16 +149,6 @@ void test_remote_httpproxy__config_overrides_detached_remote(void)
145149
146150void test_remote_httpproxy__env (void )
147151{
148- orig_http_proxy = cl_getenv ("HTTP_PROXY" );
149- orig_https_proxy = cl_getenv ("HTTPS_PROXY" );
150- orig_no_proxy = cl_getenv ("NO_PROXY" );
151- orig_proxies_need_reset = 1 ;
152-
153- /* Clear everything for a fresh start */
154- cl_setenv ("HTTP_PROXY" , NULL );
155- cl_setenv ("HTTPS_PROXY" , NULL );
156- cl_setenv ("NO_PROXY" , NULL );
157-
158152 /* HTTP proxy is ignored for HTTPS */
159153 cl_setenv ("HTTP_PROXY" , "http://localhost:9/" );
160154 assert_proxy_is (NULL );
0 commit comments