diff --git a/src/shared/Core/GitConfiguration.cs b/src/shared/Core/GitConfiguration.cs index e1412cf8c..1d95821f4 100644 --- a/src/shared/Core/GitConfiguration.cs +++ b/src/shared/Core/GitConfiguration.cs @@ -199,6 +199,9 @@ public bool TryGet(GitConfigurationLevel level, GitConfigurationType type, strin using (Process git = _git.CreateProcess($"config --null {levelArg} {typeArg} {QuoteCmdArg(name)}")) { git.Start(); + // To avoid deadlocks, always read the output stream first and then wait + // TODO: don't read in all the data at once; stream it + string data = git.StandardOutput.ReadToEnd(); git.WaitForExit(); switch (git.ExitCode) @@ -214,7 +217,6 @@ public bool TryGet(GitConfigurationLevel level, GitConfigurationType type, strin return false; } - string data = git.StandardOutput.ReadToEnd(); string[] entries = data.Split('\0'); if (entries.Length > 0) { @@ -301,7 +303,7 @@ public IEnumerable GetAll(GitConfigurationLevel level, GitConfigurationT using (Process git = _git.CreateProcess(gitArgs)) { git.Start(); - + // To avoid deadlocks, always read the output stream first and then wait // TODO: don't read in all the data at once; stream it string data = git.StandardOutput.ReadToEnd(); git.WaitForExit();