From 0dc73cbc0d2032a748d216e0018f72ea6e5b100b Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 4 Aug 2023 19:00:21 +0800 Subject: [PATCH] optimize: use custom stash instead of --autostash to avoid data missing when file is locked by other applications --- src/Commands/Pull.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Commands/Pull.cs b/src/Commands/Pull.cs index a93d962f..f447c52e 100644 --- a/src/Commands/Pull.cs +++ b/src/Commands/Pull.cs @@ -13,6 +13,7 @@ namespace SourceGit.Commands { Cwd = repo; TraitErrorAsOutput = true; handler = onProgress; + needStash = autoStash; var sshKey = new Config(repo).Get($"remote.{remote}.sshkey"); if (!string.IsNullOrEmpty(sshKey)) { @@ -23,13 +24,7 @@ namespace SourceGit.Commands { } Args += "pull --verbose --progress --tags "; - if (useRebase) Args += "--rebase "; - if (autoStash) { - if (useRebase) Args += "--autostash "; - else needStash = true; - } - Args += $"{remote} {branch}"; } @@ -46,7 +41,7 @@ namespace SourceGit.Commands { } var succ = Exec(); - if (needStash) new Stash(Cwd).Pop("stash@{0}"); + if (succ && needStash) new Stash(Cwd).Pop("stash@{0}"); return succ; }