Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/shared/Core.Tests/GitConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,5 +656,31 @@ public void GitConfiguration_TypedQuery_CanonicalizesValues()
// Value should be canonicalized path, not raw "~/example"
Assert.NotEqual("~/example", value);
}

[Fact]
public void GitConfiguration_ScopedConfig_ProcessesIncludes()
{
const string configKey = "test.value";
const string configValue = "foo123";
string repoPath = CreateRepository(out string workDirPath);
ExecGit(repoPath, workDirPath, $"config --file {workDirPath}/git.config {configKey} {configValue}").AssertSuccess();
ExecGit(repoPath, workDirPath, $"config --global include.path {workDirPath}/git.config").AssertSuccess();
ExecGit(repoPath, workDirPath, $"config --local include.path {workDirPath}/git.config").AssertSuccess();

string gitPath = GetGitPath();
var trace = new NullTrace();
var trace2 = new NullTrace2();
var processManager = new TestProcessManager();

var git = new GitProcess(trace, trace2, processManager, gitPath, repoPath);
IGitConfiguration config = git.GetConfiguration();

// value of included file set in scopes
foreach (var scope in new GitConfigurationLevel[] { GitConfigurationLevel.Global, GitConfigurationLevel.Local })
{
Assert.True(config.TryGet(scope, GitConfigurationType.Raw, configKey, out string value));
Assert.Equal(configValue, value);
}
}
}
}
8 changes: 4 additions & 4 deletions src/shared/Core/GitConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public void Enumerate(GitConfigurationLevel level, GitConfigurationEnumerationCa

// Fall back to original implementation
string levelArg = GetLevelFilterArg(level);
using (ChildProcess git = _git.CreateProcess($"config --null {levelArg} --list"))
using (ChildProcess git = _git.CreateProcess($"config --null {levelArg} --includes --list"))
{
git.Start(Trace2ProcessClass.Git);
// To avoid deadlocks, always read the output stream first and then wait
Expand Down Expand Up @@ -545,7 +545,7 @@ public bool TryGet(GitConfigurationLevel level, GitConfigurationType type, strin
// Fall back to individual git config command if cache not available
string levelArg = GetLevelFilterArg(level);
string typeArg = GetCanonicalizeTypeArg(type);
using (ChildProcess git = _git.CreateProcess($"config --null {levelArg} {typeArg} {QuoteCmdArg(name)}"))
using (ChildProcess git = _git.CreateProcess($"config --null {levelArg} --includes {typeArg} {QuoteCmdArg(name)}"))
{
git.Start(Trace2ProcessClass.Git);
// To avoid deadlocks, always read the output stream first and then wait
Expand Down Expand Up @@ -667,7 +667,7 @@ public IEnumerable<string> GetAll(GitConfigurationLevel level, GitConfigurationT
string levelArg = GetLevelFilterArg(level);
string typeArg = GetCanonicalizeTypeArg(type);

var gitArgs = $"config --null {levelArg} {typeArg} --get-all {QuoteCmdArg(name)}";
var gitArgs = $"config --null {levelArg} --includes {typeArg} --get-all {QuoteCmdArg(name)}";

using (ChildProcess git = _git.CreateProcess(gitArgs))
{
Expand Down Expand Up @@ -705,7 +705,7 @@ public IEnumerable<string> GetRegex(GitConfigurationLevel level, GitConfiguratio
string levelArg = GetLevelFilterArg(level);
string typeArg = GetCanonicalizeTypeArg(type);

var gitArgs = $"config --null {levelArg} {typeArg} --get-regex {QuoteCmdArg(nameRegex)}";
var gitArgs = $"config --null {levelArg} --includes {typeArg} --get-regex {QuoteCmdArg(nameRegex)}";
if (valueRegex != null)
{
gitArgs += $" {QuoteCmdArg(valueRegex)}";
Expand Down
Loading