repo git: reduce the number of status commands being called on activity

This commit is contained in:
Hylke Bons 2013-01-06 12:21:54 +01:00
parent 72beb68a4c
commit c1d6289507
2 changed files with 12 additions and 9 deletions

View file

@ -230,10 +230,10 @@ namespace SparkleLib.Git {
public override bool SyncUp () public override bool SyncUp ()
{ {
if (HasLocalChanges) { string message = FormatCommitMessage ();
Add ();
string message = FormatCommitMessage (); if (message != null) {
Add ();
Commit (message); Commit (message);
} }
@ -456,11 +456,11 @@ namespace SparkleLib.Git {
// Merges the fetched changes // Merges the fetched changes
private bool Rebase () private bool Rebase ()
{ {
if (HasLocalChanges) { string message = FormatCommitMessage ();
if (message != null) {
Add (); Add ();
Commit (message);
string commit_message = FormatCommitMessage ();
Commit (commit_message);
} }
SparkleGit git; SparkleGit git;
@ -1046,7 +1046,10 @@ namespace SparkleLib.Git {
git_status.StandardOutput.ReadToEnd (); git_status.StandardOutput.ReadToEnd ();
git_status.WaitForExit (); git_status.WaitForExit ();
return message; if (string.IsNullOrWhiteSpace (message))
return null;
else
return message;
} }

View file

@ -245,12 +245,12 @@ namespace SparkleLib {
SparkleLogger.LogInfo ("Local", Name + " | Activity detected, waiting for it to settle..."); SparkleLogger.LogInfo ("Local", Name + " | Activity detected, waiting for it to settle...");
List<double> size_buffer = new List<double> (); List<double> size_buffer = new List<double> ();
DirectoryInfo info = new DirectoryInfo (LocalPath);
do { do {
if (size_buffer.Count >= 4) if (size_buffer.Count >= 4)
size_buffer.RemoveAt (0); size_buffer.RemoveAt (0);
DirectoryInfo info = new DirectoryInfo (LocalPath);
size_buffer.Add (CalculateSize (info)); size_buffer.Add (CalculateSize (info));
if (size_buffer.Count >= 4 && if (size_buffer.Count >= 4 &&