// Merges the fetched changes private bool Rebase() { if (HasLocalChanges) { Add(); string commit_message = FormatCommitMessage(); Commit(commit_message); } // 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) { // Stop when we can't rebase due to locked local files // error: cannot stat 'filename': Permission denied if (error_output.Contains("error: cannot stat")) { Error = ErrorStatus.LockedFiles; SparkleLogger.LogInfo("Git", Name + " | Error status changed to " + Error); git = new SparkleGit(LocalPath, "rebase --abort"); git.StartAndWaitForExit(); git = new SparkleGit(LocalPath, "config core.ignorecase false"); git.StartAndWaitForExit(); return(false); } else { SparkleLogger.LogInfo("Git", Name + " | Conflict detected, trying to get out..."); string rebase_apply_path = new string [] { LocalPath, ".git", "rebase-apply" }.Combine(); while (Directory.Exists(rebase_apply_path) && HasLocalChanges) { try { ResolveConflict(); } catch (IOException e) { 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(); return(true); }
// Merges the fetched changes private bool Merge() { string message = FormatCommitMessage(); if (message != null) { Add(); Commit(message); } SparkleGit git; // Stop if we're already in a merge because something went wrong if (this.in_merge) { git = new SparkleGit(LocalPath, "merge --abort"); git.StartAndWaitForExit(); return(false); } // Temporarily change the ignorecase setting to true to avoid // conflicts in file names due to letter case changes git = new SparkleGit(LocalPath, "config core.ignorecase true"); git.StartAndWaitForExit(); git = new SparkleGit(LocalPath, "merge FETCH_HEAD"); git.StartInfo.RedirectStandardOutput = false; string error_output = git.StartAndReadStandardError(); if (git.ExitCode != 0) { // Stop when we can't merge due to locked local files // error: cannot stat 'filename': Permission denied if (error_output.Contains("error: cannot stat")) { Error = ErrorStatus.UnreadableFiles; SparkleLogger.LogInfo("Git", Name + " | Error status changed to " + Error); git = new SparkleGit(LocalPath, "merge --abort"); git.StartAndWaitForExit(); git = new SparkleGit(LocalPath, "config core.ignorecase false"); git.StartAndWaitForExit(); return(false); } else { SparkleLogger.LogInfo("Git", error_output); SparkleLogger.LogInfo("Git", Name + " | Conflict detected, trying to get out..."); while (this.in_merge && HasLocalChanges) { try { ResolveConflict(); } catch (Exception e) { SparkleLogger.LogInfo("Git", Name + " | Failed to resolve conflict, trying again...", e); } } SparkleLogger.LogInfo("Git", Name + " | Conflict resolved"); } } git = new SparkleGit(LocalPath, "config core.ignorecase false"); git.StartAndWaitForExit(); return(true); }