Skip to content

Commit 8421cb7

Browse files
committed
fix(setup): avoid adding redundant guard entry
reload configuration and check for empty entry in last position
1 parent 7158f0f commit 8421cb7

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/shared/Core/Application.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,15 @@ Task IConfigurableComponent.ConfigureAsync(ConfigurationTarget target)
217217
// Clear any existing app entries in the configuration
218218
config.UnsetAll(configLevel, helperKey, Regex.Escape(appPath));
219219

220+
// Reload updated helper settings (unset only clears entries in primary file, ignores includes and alternatives)
221+
currentValues = config.GetAll(configLevel, GitConfigurationType.Raw, helperKey).ToArray();
222+
220223
// Add an empty value for `credential.helper`, which has the effect of clearing any helper value
221224
// from any lower-level Git configuration, then add a second value which is the actual executable path.
222-
config.Add(configLevel, helperKey, string.Empty);
225+
if ((currentValues.Length == 0) || !string.IsNullOrWhiteSpace(currentValues.Last()))
226+
{
227+
config.Add(configLevel, helperKey, string.Empty);
228+
}
223229
config.Add(configLevel, helperKey, appPath);
224230
}
225231

0 commit comments

Comments
 (0)