diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs
index 9e55a581..cf79841d 100644
--- a/src/Commands/Command.cs
+++ b/src/Commands/Command.cs
@@ -26,7 +26,7 @@ namespace SourceGit.Commands {
public bool Exec() {
var start = new ProcessStartInfo();
- start.FileName = Native.OS.GitExecutableFile;
+ start.FileName = Native.OS.GitInstallPath;
start.Arguments = "--no-pager -c core.quotepath=off " + Args;
start.UseShellExecute = false;
start.CreateNoWindow = true;
@@ -106,7 +106,7 @@ namespace SourceGit.Commands {
public ReadToEndResult ReadToEnd() {
var start = new ProcessStartInfo();
- start.FileName = Native.OS.GitExecutableFile;
+ start.FileName = Native.OS.GitInstallPath;
start.Arguments = "--no-pager -c core.quotepath=off " + Args;
start.UseShellExecute = false;
start.CreateNoWindow = true;
diff --git a/src/Commands/SaveChangesAsPatch.cs b/src/Commands/SaveChangesAsPatch.cs
index fa8203ac..88571632 100644
--- a/src/Commands/SaveChangesAsPatch.cs
+++ b/src/Commands/SaveChangesAsPatch.cs
@@ -18,7 +18,7 @@ namespace SourceGit.Commands {
private static bool ProcessSingleChange(string repo, Models.DiffOption opt, FileStream writer) {
var starter = new ProcessStartInfo();
starter.WorkingDirectory = repo;
- starter.FileName = Native.OS.GitExecutableFile;
+ starter.FileName = Native.OS.GitInstallPath;
starter.Arguments = $"diff --ignore-cr-at-eol --unified=4 {opt}";
starter.UseShellExecute = false;
starter.CreateNoWindow = true;
diff --git a/src/Commands/SaveRevisionFile.cs b/src/Commands/SaveRevisionFile.cs
index 61f49df1..85944a89 100644
--- a/src/Commands/SaveRevisionFile.cs
+++ b/src/Commands/SaveRevisionFile.cs
@@ -20,7 +20,7 @@ namespace SourceGit.Commands {
private static bool ExecCmd(string repo, string args, string outputFile, string inputFile = null) {
var starter = new ProcessStartInfo();
starter.WorkingDirectory = repo;
- starter.FileName = Native.OS.GitExecutableFile;
+ starter.FileName = Native.OS.GitInstallPath;
starter.Arguments = args;
starter.UseShellExecute = false;
starter.CreateNoWindow = true;
diff --git a/src/Native/MacOS.cs b/src/Native/MacOS.cs
index a4aa3ca8..4d64614d 100644
--- a/src/Native/MacOS.cs
+++ b/src/Native/MacOS.cs
@@ -6,8 +6,8 @@ using System.Text;
namespace SourceGit.Native {
[SupportedOSPlatform("macOS")]
internal class MacOS : OS.IBackend {
- public string FindGitInstallDir() {
- if (File.Exists("/usr/bin/git")) return "/usr";
+ public string FindGitExecutable() {
+ if (File.Exists("/usr/bin/git")) return "/usr/bin/git";
return string.Empty;
}
diff --git a/src/Native/OS.cs b/src/Native/OS.cs
index f21558a4..7af3ef48 100644
--- a/src/Native/OS.cs
+++ b/src/Native/OS.cs
@@ -5,7 +5,7 @@ using System.IO;
namespace SourceGit.Native {
public static class OS {
public interface IBackend {
- string FindGitInstallDir();
+ string FindGitExecutable();
string FindVSCode();
void OpenTerminal(string workdir);
@@ -14,15 +14,11 @@ namespace SourceGit.Native {
void OpenWithDefaultEditor(string file);
}
- public static string GitInstallDir {
+ public static string GitInstallPath {
get;
set;
}
- public static string GitExecutableFile {
- get => Path.Combine(GitInstallDir, "bin", OperatingSystem.IsWindows() ? "git.exe" : "git");
- }
-
public static string VSCodeExecutableFile {
get;
set;
@@ -40,8 +36,8 @@ namespace SourceGit.Native {
}
}
- public static string FindGitInstallDir() {
- return _backend?.FindGitInstallDir();
+ public static string FindGitExecutable() {
+ return _backend?.FindGitExecutable();
}
public static void OpenInFileManager(string path, bool select = false) {
diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs
index b4973baa..c7f37c10 100644
--- a/src/Native/Windows.cs
+++ b/src/Native/Windows.cs
@@ -11,14 +11,14 @@ namespace SourceGit.Native {
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)]
private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs);
- public string FindGitInstallDir() {
+ public string FindGitExecutable() {
var reg = Microsoft.Win32.RegistryKey.OpenBaseKey(
Microsoft.Win32.RegistryHive.LocalMachine,
Microsoft.Win32.RegistryView.Registry64);
var git = reg.OpenSubKey("SOFTWARE\\GitForWindows");
if (git != null) {
- return git.GetValue("InstallPath") as string;
+ return Path.Combine(git.GetValue("InstallPath") as string, "bin", "git.exe");
}
var builder = new StringBuilder("git.exe", 259);
@@ -29,15 +29,7 @@ namespace SourceGit.Native {
var exePath = builder.ToString();
if (string.IsNullOrEmpty(exePath)) return null;
- var binDir = Path.GetDirectoryName(exePath);
- var bashPath = Path.Combine(binDir, "bash.exe");
- if (File.Exists(bashPath)) return Path.GetDirectoryName(binDir);
-
- binDir = Path.Combine(Path.GetDirectoryName(binDir), "bin");
- bashPath = Path.Combine(binDir, "bash.exe");
- if (File.Exists(bashPath)) return Path.GetDirectoryName(binDir);
-
- return null;
+ return exePath;
}
public string FindVSCode() {
@@ -75,9 +67,9 @@ namespace SourceGit.Native {
}
public void OpenTerminal(string workdir) {
- var bash = Path.Combine(ViewModels.Preference.Instance.GitInstallDir, "bin", "bash.exe");
+ var bash = Path.Combine(Path.GetDirectoryName(OS.GitInstallPath), "bash.exe");
if (!File.Exists(bash)) {
- App.RaiseException("", $"Can NOT found bash.exe under '{ViewModels.Preference.Instance.GitInstallDir}'");
+ App.RaiseException(string.IsNullOrEmpty(workdir) ? "" : workdir, $"Can NOT found bash.exe under '{Path.GetDirectoryName(OS.GitInstallPath)}'");
return;
}
diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs
index d80d1fb3..49a6b543 100644
--- a/src/ViewModels/Preference.cs
+++ b/src/ViewModels/Preference.cs
@@ -26,7 +26,7 @@ namespace SourceGit.ViewModels {
_instance.Repositories.RemoveAll(x => !Directory.Exists(x.FullPath));
if (!_instance.IsGitConfigured) {
- _instance.GitInstallDir = Native.OS.FindGitInstallDir();
+ _instance.GitInstallPath = Native.OS.FindGitExecutable();
}
return _instance;
@@ -93,15 +93,15 @@ namespace SourceGit.ViewModels {
[JsonIgnore]
public bool IsGitConfigured {
- get => !string.IsNullOrEmpty(GitInstallDir) && Directory.Exists(GitInstallDir);
+ get => !string.IsNullOrEmpty(GitInstallPath) && File.Exists(GitInstallPath);
}
- public string GitInstallDir {
- get => Native.OS.GitInstallDir;
+ public string GitInstallPath {
+ get => Native.OS.GitInstallPath;
set {
- if (Native.OS.GitInstallDir != value) {
- Native.OS.GitInstallDir = value;
- OnPropertyChanged(nameof(GitInstallDir));
+ if (Native.OS.GitInstallPath != value) {
+ Native.OS.GitInstallPath = value;
+ OnPropertyChanged(nameof(GitInstallPath));
}
}
}
diff --git a/src/Views/Launcher.axaml.cs b/src/Views/Launcher.axaml.cs
index a3b6501d..6d17e383 100644
--- a/src/Views/Launcher.axaml.cs
+++ b/src/Views/Launcher.axaml.cs
@@ -16,8 +16,11 @@ namespace SourceGit.Views {
var pageId = page.Node.Id.Replace("\\", "/");
if (pageId == ctx) {
page.Notifications.Add(notice);
+ return;
}
}
+
+ if (vm.ActivePage != null) vm.ActivePage.Notifications.Add(notice);
}
}
diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml
index 8e711da8..720ffae3 100644
--- a/src/Views/Preference.axaml
+++ b/src/Views/Preference.axaml
@@ -139,8 +139,8 @@
-