diff --git a/src/Commands/CountLocalChangesWithoutUntracked.cs b/src/Commands/CountLocalChangesWithoutUntracked.cs new file mode 100644 index 00000000..afb62840 --- /dev/null +++ b/src/Commands/CountLocalChangesWithoutUntracked.cs @@ -0,0 +1,26 @@ +using System; + +namespace SourceGit.Commands +{ + public class CountLocalChangesWithoutUntracked : Command + { + public CountLocalChangesWithoutUntracked(string repo) + { + WorkingDirectory = repo; + Context = repo; + Args = "status -uno --ignore-submodules=dirty --porcelain"; + } + + public int Result() + { + var rs = ReadToEnd(); + if (rs.IsSuccess) + { + var lines = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries); + return lines.Length; + } + + return 0; + } + } +} diff --git a/src/ViewModels/Checkout.cs b/src/ViewModels/Checkout.cs index 056536b5..87f5a51c 100644 --- a/src/ViewModels/Checkout.cs +++ b/src/ViewModels/Checkout.cs @@ -30,9 +30,9 @@ namespace SourceGit.ViewModels return Task.Run(() => { - var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result(); + var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result(); var needPopStash = false; - if (changes.Count > 0) + if (changes > 0) { if (PreAction == Models.DealWithLocalChanges.StashAndReaply) { diff --git a/src/ViewModels/CheckoutCommit.cs b/src/ViewModels/CheckoutCommit.cs index 7c864f2c..25f809ef 100644 --- a/src/ViewModels/CheckoutCommit.cs +++ b/src/ViewModels/CheckoutCommit.cs @@ -30,9 +30,9 @@ namespace SourceGit.ViewModels return Task.Run(() => { - var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result(); + var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result(); var needPopStash = false; - if (changes.Count > 0) + if (changes > 0) { if (AutoStash) { diff --git a/src/ViewModels/CreateBranch.cs b/src/ViewModels/CreateBranch.cs index d8706952..148860b9 100644 --- a/src/ViewModels/CreateBranch.cs +++ b/src/ViewModels/CreateBranch.cs @@ -86,9 +86,9 @@ namespace SourceGit.ViewModels { if (CheckoutAfterCreated) { - var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result(); + var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result(); var needPopStash = false; - if (changes.Count > 0) + if (changes > 0) { if (PreAction == Models.DealWithLocalChanges.StashAndReaply) { diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index acb13483..aea558c8 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -129,9 +129,9 @@ namespace SourceGit.ViewModels return Task.Run(() => { - var changes = new Commands.QueryLocalChanges(_repo.FullPath, false).Result(); + var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result(); var needPopStash = false; - if (changes.Count > 0) + if (changes > 0) { if (PreAction == Models.DealWithLocalChanges.StashAndReaply) {