Skip to content

Commit 1540736

Browse files
committed
Handle http.* config variables pointing to files gracefully on Windows
On Windows, we would like to be able to have a default http.sslCAinfo that points to an MSys path (i.e. relative to the installation root of Git). As Git is a MinGW program, it has to handle the conversion of the MSys path into a MinGW32 path itself. Since system_path() considers paths starting with '/' as absolute, we have to convince it to make a Windows path by stripping the leading slash. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 893292c commit 1540736

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

http.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "version.h"
1010
#include "pkt-line.h"
1111
#include "gettext.h"
12+
#include "exec_cmd.h"
1213

1314
int active_requests;
1415
int http_is_verbose;
@@ -181,24 +182,36 @@ static void process_curl_messages(void)
181182
}
182183
#endif
183184

185+
static int git_config_path(const char **result,
186+
const char *var, const char *value)
187+
{
188+
if (git_config_string(result, var, value))
189+
return 1;
190+
#ifdef __MINGW32__
191+
if (**result == '/')
192+
*result = system_path((*result) + 1);
193+
#endif
194+
return 0;
195+
}
196+
184197
static int http_options(const char *var, const char *value, void *cb)
185198
{
186199
if (!strcmp("http.sslverify", var)) {
187200
curl_ssl_verify = git_config_bool(var, value);
188201
return 0;
189202
}
190203
if (!strcmp("http.sslcert", var))
191-
return git_config_string(&ssl_cert, var, value);
204+
return git_config_path(&ssl_cert, var, value);
192205
#if LIBCURL_VERSION_NUM >= 0x070903
193206
if (!strcmp("http.sslkey", var))
194-
return git_config_string(&ssl_key, var, value);
207+
return git_config_path(&ssl_key, var, value);
195208
#endif
196209
#if LIBCURL_VERSION_NUM >= 0x070908
197210
if (!strcmp("http.sslcapath", var))
198-
return git_config_string(&ssl_capath, var, value);
211+
return git_config_path(&ssl_capath, var, value);
199212
#endif
200213
if (!strcmp("http.sslcainfo", var))
201-
return git_config_string(&ssl_cainfo, var, value);
214+
return git_config_path(&ssl_cainfo, var, value);
202215
if (!strcmp("http.sslcertpasswordprotected", var)) {
203216
ssl_cert_password_required = git_config_bool(var, value);
204217
return 0;

0 commit comments

Comments
 (0)