From 0944efe992cc3779ff3a6975afbd42b9930907db Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 29 Jun 2011 20:45:37 +0100 Subject: [PATCH] repo git: don't hang on huge command outputs --- SparkleLib/Git/SparkleRepoGit.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index f0ae14d0..ef90cd3a 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -137,7 +137,6 @@ namespace SparkleLib { Commit (message); SparkleGit git = new SparkleGit (LocalPath, "push origin master"); - git.Start (); git.WaitForExit (); @@ -168,9 +167,12 @@ namespace SparkleLib { get { SparkleGit git = new SparkleGit (LocalPath, "status --porcelain"); git.Start (); + + // Reading the standard output HAS to go before + // WaitForExit, or it will hang forever on output > 4096 bytes + string output = git.StandardOutput.ReadToEnd ().TrimEnd (); git.WaitForExit (); - string output = git.StandardOutput.ReadToEnd ().TrimEnd (); string [] lines = output.Split ("\n".ToCharArray ()); foreach (string line in lines) { @@ -300,9 +302,12 @@ namespace SparkleLib { SparkleGit git_status = new SparkleGit (LocalPath, "status --porcelain"); git_status.Start (); - git_status.WaitForExit (); - string output = git_status.StandardOutput.ReadToEnd ().TrimEnd (); + // Reading the standard output HAS to go before + // WaitForExit, or it will hang forever on output > 4096 bytes + string output = git_status.StandardOutput.ReadToEnd ().TrimEnd (); + git.WaitForExit (); + string [] lines = output.Split ("\n".ToCharArray ()); foreach (string line in lines) {