Skip to content
Draft
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
7 changes: 5 additions & 2 deletions src/shared/Core/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Task IConfigurableComponent.ConfigureAsync(ConfigurationTarget target)

// Try to locate an existing app entry with a blank reset/clear entry immediately preceding,
// and no other blank empty/clear entries following (which effectively disable us).
int appIndex = Array.FindIndex(currentValues, x => Context.FileSystem.IsSamePath(x, appPath));
int appIndex = Array.FindLastIndex(currentValues, x => Context.FileSystem.IsSamePath(x, appPath));
int lastEmptyIndex = Array.FindLastIndex(currentValues, string.IsNullOrWhiteSpace);
if (appIndex > 0 && string.IsNullOrWhiteSpace(currentValues[appIndex - 1]) && lastEmptyIndex < appIndex)
{
Expand All @@ -219,7 +219,10 @@ Task IConfigurableComponent.ConfigureAsync(ConfigurationTarget target)

// Add an empty value for `credential.helper`, which has the effect of clearing any helper value
// from any lower-level Git configuration, then add a second value which is the actual executable path.
config.Add(configLevel, helperKey, string.Empty);
if ((currentValues.Length == 0) || (lastEmptyIndex != (currentValues.Length - 1)))
{
config.Add(configLevel, helperKey, string.Empty);
}
config.Add(configLevel, helperKey, appPath);
}

Expand Down
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