From 31253269aa70abd8917436b9ed863c6c8f559745 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 30 Apr 2021 09:03:35 +0800 Subject: [PATCH] fix: fix find merged commits in current branch without head --- src/Commands/Commits.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Commands/Commits.cs b/src/Commands/Commits.cs index e5839e5c..fbc7cd60 100644 --- a/src/Commands/Commits.cs +++ b/src/Commands/Commits.cs @@ -121,18 +121,19 @@ namespace SourceGit.Commands { } private void MarkFirstMerged() { - Args = $"log --since=\"{commits.Last().Committer.Time}\" --min-parents=2 --format=\"%H\""; + Args = $"log --since=\"{commits.Last().Committer.Time}\" --format=\"%H\""; var rs = ReadToEnd(); var shas = rs.Output.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); if (shas.Length == 0) return; - var merges = commits.Where(x => x.Parents.Count > 1).ToList(); - foreach (var sha in shas) { - var c = merges.Find(x => x.SHA == sha); - if (c != null) { + var set = new HashSet(); + foreach (var sha in shas) set.Add(sha); + + foreach (var c in commits) { + if (set.Contains(c.SHA)) { c.IsMerged = true; - return; + break; } } }