From 9bcbec8d84c553382b073a3ce6e4f0bdea0773ca Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 11 Nov 2012 19:15:42 +0000 Subject: [PATCH] repo git: temporarily set core.ignorecase=true when rebasing to prevent conflicts. fixes #721 --- SparkleLib/Git/SparkleGit.cs | 16 +++++++++++++++- SparkleLib/Git/SparkleRepoGit.cs | 28 +++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/SparkleLib/Git/SparkleGit.cs b/SparkleLib/Git/SparkleGit.cs index f821f38c..3251091f 100644 --- a/SparkleLib/Git/SparkleGit.cs +++ b/SparkleLib/Git/SparkleGit.cs @@ -56,12 +56,26 @@ namespace SparkleLib.Git { public string StartAndReadStandardOutput () { Start (); - + // Reading the standard output HAS to go before // WaitForExit, or it will hang forever on output > 4096 bytes string output = StandardOutput.ReadToEnd (); WaitForExit (); + + return output.TrimEnd (); + } + + public string StartAndReadStandardError () + { + StartInfo.RedirectStandardError = true; + Start (); + + // Reading the standard output HAS to go before + // WaitForExit, or it will hang forever on output > 4096 bytes + string output = StandardError.ReadToEnd (); + WaitForExit (); + return output.TrimEnd (); } diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index 961604fa..fe940b26 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -37,8 +37,11 @@ namespace SparkleLib.Git { { // TODO: Set git locale to en-US + SparkleGit git = new SparkleGit (LocalPath, "config core.ignorecase false"); + git.StartAndWaitForExit (); + // Check if we should use git-bin - SparkleGit git = new SparkleGit (LocalPath, "config --get filter.bin.clean"); + git = new SparkleGit (LocalPath, "config --get filter.bin.clean"); git.StartAndWaitForExit (); this.use_git_bin = (git.ExitCode == 0); @@ -415,26 +418,41 @@ namespace SparkleLib.Git { Commit (commit_message); } - SparkleGit git = new SparkleGit (LocalPath, "rebase FETCH_HEAD"); - git.StartInfo.RedirectStandardOutput = false; + // Temporarily change the ignorecase setting to true to avoid + // conflicts in file names due to case changes + SparkleGit git = new SparkleGit (LocalPath, "config core.ignorecase true"); git.StartAndWaitForExit (); + git = new SparkleGit (LocalPath, "rebase FETCH_HEAD"); + git.StartInfo.RedirectStandardOutput = false; + + string error_output = git.StartAndReadStandardError (); + if (git.ExitCode != 0) { SparkleLogger.LogInfo ("Git", Name + " | Conflict detected, trying to get out..."); + // error: cannot stat 'filename': Permission denied + if (SparkleBackend.Platform != PlatformID.Unix && + error_output.Contains ("error: cannot stat")) { + + // TODO + } + while (HasLocalChanges) { try { ResolveConflict (); } catch (IOException e) { - SparkleLogger.LogInfo ("Git", - Name + " | Failed to resolve conflict, trying again... (" + e.Message + ")"); + SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again... (" + e.Message + ")"); } } SparkleLogger.LogInfo ("Git", Name + " | Conflict resolved"); OnConflictResolved (); } + + git = new SparkleGit (LocalPath, "config core.ignorecase false"); + git.StartAndWaitForExit (); }