Skip to content

Commit 475c6eb

Browse files
committed
win32: improve impl & tests for system path / g4w interop
We look for a Git for Windows installation to use its git config, so that clients built on libgit2 can interoperate with the Git for Windows CLI (and clients that are built on top of _it_). Look for `git` both in the `PATH` and in the registry. Use the _first_ git install in the path, and the first git install in the registry. Look in both the `etc` dir and the architecture-specific `etc` dirs (`mingw64/etc` and `mingw32/etc`) beneath the installation root. Prefer the git in the `PATH` to the git location in the registry so that users can override that. Include more tests for this behavior.
1 parent 925abee commit 475c6eb

File tree

5 files changed

+490
-271
lines changed

5 files changed

+490
-271
lines changed

src/sysdir.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static int git_sysdir_guess_programdata_dirs(git_str *out)
3131
static int git_sysdir_guess_system_dirs(git_str *out)
3232
{
3333
#ifdef GIT_WIN32
34-
return git_win32__find_system_dirs(out, L"etc\\");
34+
return git_win32__find_system_dirs(out, "etc");
3535
#else
3636
return git_str_sets(out, "/etc");
3737
#endif
@@ -154,7 +154,7 @@ static int git_sysdir_guess_xdg_dirs(git_str *out)
154154
static int git_sysdir_guess_template_dirs(git_str *out)
155155
{
156156
#ifdef GIT_WIN32
157-
return git_win32__find_system_dirs(out, L"share\\git-core\\templates");
157+
return git_win32__find_system_dirs(out, "share/git-core/templates");
158158
#else
159159
return git_str_sets(out, "/usr/share/git-core/templates");
160160
#endif
@@ -190,22 +190,22 @@ int git_sysdir_global_init(void)
190190
error = git_sysdir__dirs[i].guess(&git_sysdir__dirs[i].buf);
191191

192192
if (error)
193-
return error;
193+
return error;
194194

195195
return git_runtime_shutdown_register(git_sysdir_global_shutdown);
196196
}
197197

198198
int git_sysdir_reset(void)
199199
{
200-
size_t i;
201-
int error = 0;
200+
size_t i;
201+
int error = 0;
202202

203-
for (i = 0; !error && i < ARRAY_SIZE(git_sysdir__dirs); ++i) {
204-
git_str_dispose(&git_sysdir__dirs[i].buf);
205-
error = git_sysdir__dirs[i].guess(&git_sysdir__dirs[i].buf);
206-
}
203+
for (i = 0; !error && i < ARRAY_SIZE(git_sysdir__dirs); ++i) {
204+
git_str_dispose(&git_sysdir__dirs[i].buf);
205+
error = git_sysdir__dirs[i].guess(&git_sysdir__dirs[i].buf);
206+
}
207207

208-
return error;
208+
return error;
209209
}
210210

211211
static int git_sysdir_check_selector(git_sysdir_t which)

0 commit comments

Comments
 (0)