From 8ca9cadf3cc38a2b5aa1d9ef01593a76180f9310 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 20 Apr 2014 11:34:01 +0100 Subject: [PATCH] repo git: Strip rename indicators from conflict path names. Fixes #1459 --- SparkleLib/Git/SparkleRepoGit.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index 890bddc4..ff427eb4 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -531,7 +531,7 @@ namespace SparkleLib.Git { try { ResolveConflict (); - } catch (IOException e) { + } catch (Exception e) { SparkleLogger.LogInfo ("Git", Name + " | Failed to resolve conflict, trying again...", e); } } @@ -572,9 +572,18 @@ namespace SparkleLib.Git { conflicting_path = EnsureSpecialCharacters (conflicting_path); conflicting_path = conflicting_path.Trim ("\"".ToCharArray ()); + // Remove possible rename indicators + string [] separators = {" -> \"", " -> "}; + foreach (string separator in separators) { + if (conflicting_path.Contains (separator)) { + conflicting_path = conflicting_path.Substring ( + conflicting_path.IndexOf (separator) + separator.Length); + } + } + SparkleLogger.LogInfo ("Git", Name + " | Conflict type: " + line); - // Ignore conflicts in the .sparkleshare file and use the local version + // Ignore conflicts in hidden files and use the local versions if (conflicting_path.EndsWith (".sparkleshare") || conflicting_path.EndsWith (".empty")) { SparkleLogger.LogInfo ("Git", Name + " | Ignoring conflict in special file: " + conflicting_path); @@ -582,7 +591,10 @@ namespace SparkleLib.Git { SparkleGit git_ours = new SparkleGit (LocalPath, "checkout --ours \"" + conflicting_path + "\""); git_ours.StartAndWaitForExit (); - File.SetAttributes (Path.Combine (LocalPath, conflicting_path), FileAttributes.Hidden); + string abs_conflicting_path = Path.Combine (LocalPath, conflicting_path); + + if (File.Exists (abs_conflicting_path)) + File.SetAttributes (abs_conflicting_path, FileAttributes.Hidden); continue; }