fix<Commits>: fix find merged commits in current branch without head

This commit is contained in:
leo 2021-04-30 09:03:35 +08:00
parent 50ad4a0278
commit 31253269aa

View file

@ -121,18 +121,19 @@ namespace SourceGit.Commands {
} }
private void MarkFirstMerged() { 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 rs = ReadToEnd();
var shas = rs.Output.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); var shas = rs.Output.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
if (shas.Length == 0) return; if (shas.Length == 0) return;
var merges = commits.Where(x => x.Parents.Count > 1).ToList(); var set = new HashSet<string>();
foreach (var sha in shas) { foreach (var sha in shas) set.Add(sha);
var c = merges.Find(x => x.SHA == sha);
if (c != null) { foreach (var c in commits) {
if (set.Contains(c.SHA)) {
c.IsMerged = true; c.IsMerged = true;
return; break;
} }
} }
} }