From ca6070b386f5c691daa3d27abc23920f3433fbf6 Mon Sep 17 00:00:00 2001 From: Alex Hudson Date: Mon, 2 Aug 2010 22:01:16 +0100 Subject: [PATCH] Don't fall over when looking at activities of a cloned empty repo. --- SparkleShare/SparkleWindow.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SparkleShare/SparkleWindow.cs b/SparkleShare/SparkleWindow.cs index ff569d26..05de3d28 100644 --- a/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -110,14 +110,15 @@ namespace SparkleShare { process.StartInfo.FileName = "git"; process.StartInfo.Arguments = "log --format=\"%at☃%an☃%ae☃%s\" -" + number_of_events; - string output = ""; - process.Start (); - output += "\n" + process.StandardOutput.ReadToEnd ().Trim (); + string output = process.StandardOutput.ReadToEnd ().Trim (); output = output.TrimStart ("\n".ToCharArray ()); string [] lines = Regex.Split (output, "\n"); + int linesLength = lines.Length; + if (output == "") + linesLength = 0; // Sort by time and get the last 25 Array.Sort (lines); @@ -125,7 +126,7 @@ namespace SparkleShare { List activity_days = new List (); - for (int i = 0; i < number_of_events && i < lines.Length; i++) { + for (int i = 0; i < number_of_events && i < linesLength; i++) { string line = lines [i];