94
static int http_options(const char *var, const char *value, void *cb)
95
{
96
if (!strcmp("http.sslverify", var)) {
97
- if (curl_ssl_verify == -1)
98
- curl_ssl_verify = git_config_bool(var, value);
99
- return 0;
100
- }
101
-
102
- if (!strcmp("http.sslcert", var)) {
103
- if (ssl_cert == NULL)
104
- return git_config_string(&ssl_cert, var, value);
97
+ curl_ssl_verify = git_config_bool(var, value);
98
return 0;
99
}
100
+ if (!strcmp("http.sslcert", var))
101
+ return git_config_string(&ssl_cert, var, value);
102
#if LIBCURL_VERSION_NUM >= 0x070902
108
- if (!strcmp("http.sslkey", var)) {
109
- if (ssl_key == NULL)
110
- return git_config_string(&ssl_key, var, value);
111
- return 0;
112
- }
103
+ if (!strcmp("http.sslkey", var))
104
+ return git_config_string(&ssl_key, var, value);
105
#endif
106
#if LIBCURL_VERSION_NUM >= 0x070908
115
- if (!strcmp("http.sslcapath", var)) {
116
- if (ssl_capath == NULL)
117
- return git_config_string(&ssl_capath, var, value);
118
- return 0;
119
- }
107
+ if (!strcmp("http.sslcapath", var))
108
+ return git_config_string(&ssl_capath, var, value);
109
#endif
121
- if (!strcmp("http.sslcainfo", var)) {
122
- if (ssl_cainfo == NULL)
123
- return git_config_string(&ssl_cainfo, var, value);
124
- return 0;
125
- }
126
-
110
+ if (!strcmp("http.sslcainfo", var))
111
+ return git_config_string(&ssl_cainfo, var, value);
112
#ifdef USE_CURL_MULTI
113
if (!strcmp("http.maxrequests", var)) {
129
- if (max_requests == -1)
130
- max_requests = git_config_int(var, value);
114
+ max_requests = git_config_int(var, value);
115
return 0;
116
}
117
#endif
134
-
118
if (!strcmp("http.lowspeedlimit", var)) {
136
- if (curl_low_speed_limit == -1)
137
- curl_low_speed_limit = (long)git_config_int(var, value);
119
+ curl_low_speed_limit = (long)git_config_int(var, value);
120
return 0;
121
}
122
if (!strcmp("http.lowspeedtime", var)) {
141
- if (curl_low_speed_time == -1)
142
- curl_low_speed_time = (long)git_config_int(var, value);
123
+ curl_low_speed_time = (long)git_config_int(var, value);
124
return 0;
125
}
126
128
curl_ftp_no_epsv = git_config_bool(var, value);
129
return 0;
130
}
150
- if (!strcmp("http.proxy", var)) {
151
- if (curl_http_proxy == NULL)
152
- return git_config_string(&curl_http_proxy, var, value);
153
- return 0;
154
- }
131
+ if (!strcmp("http.proxy", var))
132
+ return git_config_string(&curl_http_proxy, var, value);
133
134
/* Fall back on the default ones */
135
return git_default_config(var, value, cb);
190
return result;
191
}
192
193
+static void set_from_env(const char **var, const char *envname)
194
+{
195
+ const char *val = getenv(envname);
196
+ if (val)
197
+ *var = val;
198
+}
199
+
200
void http_init(struct remote *remote)
201
{
202
char *low_speed_limit;
203
char *low_speed_time;
204
205
+ git_config(http_options, NULL);
206
+
207
curl_global_init(CURL_GLOBAL_ALL);
208
209
if (remote && remote->http_proxy)
228
if (getenv("GIT_SSL_NO_VERIFY"))
229
curl_ssl_verify = 0;
230
244
- ssl_cert = getenv("GIT_SSL_CERT");
231
+ set_from_env(&ssl_cert, "GIT_SSL_CERT");
232
#if LIBCURL_VERSION_NUM >= 0x070902
246
- ssl_key = getenv("GIT_SSL_KEY");
233
+ set_from_env(&ssl_key, "GIT_SSL_KEY");
234
#endif
235
#if LIBCURL_VERSION_NUM >= 0x070908
249
- ssl_capath = getenv("GIT_SSL_CAPATH");
236
+ set_from_env(&ssl_capath, "GIT_SSL_CAPATH");
237
#endif
251
- ssl_cainfo = getenv("GIT_SSL_CAINFO");
238
+ set_from_env(&ssl_cainfo, "GIT_SSL_CAINFO");
239
240
low_speed_limit = getenv("GIT_HTTP_LOW_SPEED_LIMIT");
241
if (low_speed_limit != NULL)
244
if (low_speed_time != NULL)
245
curl_low_speed_time = strtol(low_speed_time, NULL, 10);
246
260
- git_config(http_options, NULL);
261
-
247
if (curl_ssl_verify == -1)
248
curl_ssl_verify = 1;
249