Skip to content

Commit cee2ef3

Browse files
dschokblees
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 20ba112 commit cee2ef3

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
@@ -7,6 +7,7 @@
77
#include "credential.h"
88
#include "version.h"
99
#include "pkt-line.h"
10+
#include "exec_cmd.h"
1011

1112
int active_requests;
1213
int http_is_verbose;
@@ -143,24 +144,36 @@ static void process_curl_messages(void)
143144
}
144145
#endif
145146

147+
static int git_config_path(const char **result,
148+
const char *var, const char *value)
149+
{
150+
if (git_config_string(result, var, value))
151+
return 1;
152+
#ifdef __MINGW32__
153+
if (**result == '/')
154+
*result = system_path((*result) + 1);
155+
#endif
156+
return 0;
157+
}
158+
146159
static int http_options(const char *var, const char *value, void *cb)
147160
{
148161
if (!strcmp("http.sslverify", var)) {
149162
curl_ssl_verify = git_config_bool(var, value);
150163
return 0;
151164
}
152165
if (!strcmp("http.sslcert", var))
153-
return git_config_string(&ssl_cert, var, value);
166+
return git_config_path(&ssl_cert, var, value);
154167
#if LIBCURL_VERSION_NUM >= 0x070903
155168
if (!strcmp("http.sslkey", var))
156-
return git_config_string(&ssl_key, var, value);
169+
return git_config_path(&ssl_key, var, value);
157170
#endif
158171
#if LIBCURL_VERSION_NUM >= 0x070908
159172
if (!strcmp("http.sslcapath", var))
160-
return git_config_string(&ssl_capath, var, value);
173+
return git_config_path(&ssl_capath, var, value);
161174
#endif
162175
if (!strcmp("http.sslcainfo", var))
163-
return git_config_string(&ssl_cainfo, var, value);
176+
return git_config_path(&ssl_cainfo, var, value);
164177
if (!strcmp("http.sslcertpasswordprotected", var)) {
165178
ssl_cert_password_required = git_config_bool(var, value);
166179
return 0;

0 commit comments

Comments
 (0)