Skip to content

Commit cdc1844

Browse files
dschonalla
authored andcommitted
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 c25fa2e commit cdc1844

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
@@ -8,6 +8,7 @@
88
#include "credential.h"
99
#include "version.h"
1010
#include "pkt-line.h"
11+
#include "exec_cmd.h"
1112

1213
int active_requests;
1314
int http_is_verbose;
@@ -147,24 +148,36 @@ static void process_curl_messages(void)
147148
}
148149
#endif
149150

151+
static int git_config_path(const char **result,
152+
const char *var, const char *value)
153+
{
154+
if (git_config_string(result, var, value))
155+
return 1;
156+
#ifdef __MINGW32__
157+
if (**result == '/')
158+
*result = system_path((*result) + 1);
159+
#endif
160+
return 0;
161+
}
162+
150163
static int http_options(const char *var, const char *value, void *cb)
151164
{
152165
if (!strcmp("http.sslverify", var)) {
153166
curl_ssl_verify = git_config_bool(var, value);
154167
return 0;
155168
}
156169
if (!strcmp("http.sslcert", var))
157-
return git_config_string(&ssl_cert, var, value);
170+
return git_config_path(&ssl_cert, var, value);
158171
#if LIBCURL_VERSION_NUM >= 0x070903
159172
if (!strcmp("http.sslkey", var))
160-
return git_config_string(&ssl_key, var, value);
173+
return git_config_path(&ssl_key, var, value);
161174
#endif
162175
#if LIBCURL_VERSION_NUM >= 0x070908
163176
if (!strcmp("http.sslcapath", var))
164-
return git_config_string(&ssl_capath, var, value);
177+
return git_config_path(&ssl_capath, var, value);
165178
#endif
166179
if (!strcmp("http.sslcainfo", var))
167-
return git_config_string(&ssl_cainfo, var, value);
180+
return git_config_path(&ssl_cainfo, var, value);
168181
if (!strcmp("http.sslcertpasswordprotected", var)) {
169182
ssl_cert_password_required = git_config_bool(var, value);
170183
return 0;

0 commit comments

Comments
 (0)