diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index 5275a479..b003167a 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -42,6 +42,11 @@ namespace SourceGit.Commands { /// public string Args { get; set; } = ""; + /// + /// 是否忽略错误 + /// + public bool DontRaiseError { get; set; } = false; + /// /// 使用标准错误输出 /// @@ -115,7 +120,7 @@ namespace SourceGit.Commands { proc.Close(); if (!isCancelled && exitCode != 0 && errs.Count > 0) { - Models.Exception.Raise(string.Join("\n", errs)); + if (!DontRaiseError) Models.Exception.Raise(string.Join("\n", errs)); return false; } else { return true; diff --git a/src/Models/MergeTool.cs b/src/Models/MergeTool.cs index 3c8f25b7..5108cb93 100644 --- a/src/Models/MergeTool.cs +++ b/src/Models/MergeTool.cs @@ -22,6 +22,7 @@ namespace SourceGit.Models { new MergeTool(3, "Tortoise Merge", "TortoiseMerge.exe", "-base:\"$BASE\" -theirs:\"$REMOTE\" -mine:\"$LOCAL\" -merged:\"$MERGED\"", FindTortoiseMerge), new MergeTool(4, "KDiff3", "kdiff3.exe", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", FindKDiff3), new MergeTool(5, "Beyond Compare 4", "BComp.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", FindBCompare), + new MergeTool(6, "WinMerge", "WinMergeU.exe", "-u -e \"$REMOTE\" \"$LOCAL\" \"$MERGED\"", FindWinMerge), }; public MergeTool(int type, string name, string exec, string cmd, Func finder) { @@ -115,5 +116,17 @@ namespace SourceGit.Models { var dir = Path.GetDirectoryName(exec); return $"{dir}\\BComp.exe"; } + + private static string FindWinMerge() { + var root = RegistryKey.OpenBaseKey( + RegistryHive.CurrentUser, + Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32); + + var merge = root.OpenSubKey(@"SOFTWARE\Thingamahoochie\WinMerge"); + if (merge == null) return ""; + + var exec = merge.GetValue("Executable") as string; + return exec; + } } } diff --git a/src/Views/Widgets/WorkingCopy.xaml.cs b/src/Views/Widgets/WorkingCopy.xaml.cs index 4173a812..3f293db4 100644 --- a/src/Views/Widgets/WorkingCopy.xaml.cs +++ b/src/Views/Widgets/WorkingCopy.xaml.cs @@ -200,6 +200,7 @@ namespace SourceGit.Views.Widgets { var cmd = new Commands.Command(); cmd.Cwd = repo.Path; + cmd.DontRaiseError = true; cmd.Args = $"-c mergetool.sourcegit.cmd=\"\\\"{mergeExe}\\\" {merger.Cmd}\" "; cmd.Args += "-c mergetool.writeToTemp=true -c mergetool.keepBackup=false -c mergetool.trustExitCode=true "; cmd.Args += $"mergetool --tool=sourcegit {change.Path}";