repo git: don't hang on huge command outputs

This commit is contained in:
Hylke Bons 2011-06-29 20:45:37 +01:00
parent de564d89ff
commit cfbdf98150

View file

@ -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) {