mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
fix<Preference>: fix open Preference crash when git.exe is not configured
This commit is contained in:
parent
a70152ee8a
commit
ad0d1f0ab8
1 changed files with 19 additions and 11 deletions
|
@ -16,10 +16,16 @@ namespace SourceGit.Views {
|
|||
public string MergeCmd { get; set; }
|
||||
|
||||
public Preference() {
|
||||
User = new Commands.Config().Get("user.name");
|
||||
Email = new Commands.Config().Get("user.email");
|
||||
CRLF = new Commands.Config().Get("core.autocrlf");
|
||||
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
||||
if (Models.Preference.Instance.IsReady) {
|
||||
User = new Commands.Config().Get("user.name");
|
||||
Email = new Commands.Config().Get("user.email");
|
||||
CRLF = new Commands.Config().Get("core.autocrlf");
|
||||
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
||||
} else {
|
||||
User = "";
|
||||
Email = "";
|
||||
CRLF = "false";
|
||||
}
|
||||
|
||||
var merger = Models.MergeTool.Supported.Find(x => x.Type == Models.Preference.Instance.MergeTool.Type);
|
||||
if (merger != null) MergeCmd = merger.Cmd;
|
||||
|
@ -83,15 +89,17 @@ namespace SourceGit.Views {
|
|||
}
|
||||
|
||||
private void Quit(object sender, RoutedEventArgs e) {
|
||||
var cmd = new Commands.Config();
|
||||
var oldUser = cmd.Get("user.name");
|
||||
if (oldUser != User) cmd.Set("user.name", User);
|
||||
if (Models.Preference.Instance.IsReady) {
|
||||
var cmd = new Commands.Config();
|
||||
var oldUser = cmd.Get("user.name");
|
||||
if (oldUser != User) cmd.Set("user.name", User);
|
||||
|
||||
var oldEmail = cmd.Get("user.email");
|
||||
if (oldEmail != Email) cmd.Set("user.email", Email);
|
||||
var oldEmail = cmd.Get("user.email");
|
||||
if (oldEmail != Email) cmd.Set("user.email", Email);
|
||||
|
||||
var oldCRLF = cmd.Get("core.autocrlf");
|
||||
if (oldCRLF != CRLF) cmd.Set("core.autocrlf", CRLF);
|
||||
var oldCRLF = cmd.Get("core.autocrlf");
|
||||
if (oldCRLF != CRLF) cmd.Set("core.autocrlf", CRLF);
|
||||
}
|
||||
|
||||
Models.Preference.Save();
|
||||
Close();
|
||||
|
|
Loading…
Reference in a new issue