Skip to content

Commit ebc43b4

Browse files
committed
Teach the custom config builder about ProgramData
1 parent 06d2866 commit ebc43b4

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

LibGit2Sharp/Configuration.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class Configuration : IDisposable,
1919
private readonly FilePath globalConfigPath;
2020
private readonly FilePath xdgConfigPath;
2121
private readonly FilePath systemConfigPath;
22+
private readonly FilePath programDataConfigPath;
2223

2324
private ConfigurationSafeHandle configHandle;
2425

@@ -43,6 +44,7 @@ internal Configuration(
4344
globalConfigPath = globalConfigurationFileLocation ?? Proxy.git_config_find_global();
4445
xdgConfigPath = xdgConfigurationFileLocation ?? Proxy.git_config_find_xdg();
4546
systemConfigPath = systemConfigurationFileLocation ?? Proxy.git_config_find_system();
47+
programDataConfigPath = Proxy.git_config_find_programdata();
4648

4749
Init(repository);
4850
}
@@ -81,6 +83,11 @@ private void Init(Repository repository)
8183
{
8284
Proxy.git_config_add_file_ondisk(configHandle, systemConfigPath, ConfigurationLevel.System);
8385
}
86+
87+
if (programDataConfigPath != null)
88+
{
89+
Proxy.git_config_add_file_ondisk(configHandle, programDataConfigPath, ConfigurationLevel.ProgramData);
90+
}
8491
}
8592

8693
private FilePath NormalizeConfigPath(FilePath path)

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ internal static extern int git_config_delete_multivar(
344344
[DllImport(libgit2)]
345345
internal static extern int git_config_find_xdg(GitBuf xdg_config_path);
346346

347+
[DllImport(libgit2)]
348+
internal static extern int git_config_find_programdata(GitBuf programdata_config_path);
349+
347350
[DllImport(libgit2)]
348351
internal static extern void git_config_free(IntPtr cfg);
349352

LibGit2Sharp/Core/Proxy.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,11 @@ public static FilePath git_config_find_xdg()
468468
return ConvertPath(NativeMethods.git_config_find_xdg);
469469
}
470470

471+
public static FilePath git_config_find_programdata()
472+
{
473+
return ConvertPath(NativeMethods.git_config_find_programdata);
474+
}
475+
471476
public static void git_config_free(IntPtr config)
472477
{
473478
NativeMethods.git_config_free(config);

0 commit comments

Comments
 (0)