6
6
static git_repository * repo ;
7
7
static git_net_url url = GIT_NET_URL_INIT ;
8
8
9
- static int orig_proxies_need_reset = 0 ;
10
9
static char * orig_http_proxy = NULL ;
11
10
static char * orig_https_proxy = NULL ;
12
11
static char * orig_no_proxy = NULL ;
@@ -21,20 +20,25 @@ void test_remote_httpproxy__initialize(void)
21
20
22
21
git_remote_free (remote );
23
22
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
8000
_proxy = cl_getenv ("NO_PROXY" );
27
+
28
+ cl_setenv ("HTTP_PROXY" , NULL );
29
+ cl_setenv ("HTTPS_PROXY" , NULL );
30
+ cl_setenv ("NO_PROXY" , NULL );
25
31
}
26
32
27
33
void test_remote_httpproxy__cleanup (void )
28
34
{
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 );
38
42
39
43
git_net_url_dispose (& url );
40
44
cl_git_sandbox_cleanup ();
@@ -145,16 +149,6 @@ void test_remote_httpproxy__config_overrides_detached_remote(void)
145
149
146
150
void test_remote_httpproxy__env (void )
147
151
{
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
-
158
152
/* HTTP proxy is ignored for HTTPS */
159
153
cl_setenv ("HTTP_PROXY" , "http://localhost:9/" );
160
154
assert_proxy_is (NULL );
0 commit comments