Skip to content

Commit f5c347c

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 a7f17aa commit f5c347c

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;
@@ -144,24 +145,36 @@ static void process_curl_messages(void)
144145
}
145146
#endif
146147

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

0 commit comments

Comments
 (0)