From 6213b95ef16d7497e7fefd9b20307186d588ddcc Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 21 Apr 2011 23:14:44 +0200 Subject: [PATCH] [repo] add back empty repo check without Git# --- SparkleLib/SparkleRepo.cs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/SparkleLib/SparkleRepo.cs b/SparkleLib/SparkleRepo.cs index a3720ec1..8b7ead2d 100644 --- a/SparkleLib/SparkleRepo.cs +++ b/SparkleLib/SparkleRepo.cs @@ -141,13 +141,6 @@ namespace SparkleLib { Description = GetDescription (); UserName = GetUserName (); UserEmail = GetUserEmail (); - - // TODO: replace this with a check on the number of objects in .git/objects/ (empty if 2) - // if (Head.CurrentCommit == null) - // _CurrentHash = null; - // else - _CurrentHash = GetCurrentHash (); - _IsSyncing = false; _IsBuffering = false; _IsPolling = true; @@ -158,6 +151,11 @@ namespace SparkleLib { ChangeLock = new Object (); FetchRequests = 0; + if (IsEmpty) + _CurrentHash = null; + else + _CurrentHash = GetCurrentHash (); + string unsynced_file_path = SparkleHelpers.CombineMore (LocalPath, ".git", "has_unsynced_changes"); @@ -408,7 +406,7 @@ namespace SparkleLib { } - public bool AnyDifferences { + private bool AnyDifferences { get { SparkleGit git = new SparkleGit (LocalPath, "status --porcelain"); git.Start (); @@ -427,6 +425,17 @@ namespace SparkleLib { } + private bool IsEmpty { + get { + SparkleGit git = new SparkleGit (LocalPath, "log -1"); + git.Start (); + git.WaitForExit (); + + return (git.ExitCode != 0); + } + } + + private string GetCurrentHash () { SparkleGit git = new SparkleGit (LocalPath, "log -1 --format=%H");