From ba7873c08a8df20e511c0becda8af021f06ce426 Mon Sep 17 00:00:00 2001 From: Felix Herbst Date: Sun, 19 Jan 2020 15:48:23 +0100 Subject: [PATCH] Return all changes to a file when using Repository.Commits.QueryBy(path) --- LibGit2Sharp/Core/FileHistory.cs | 33 +++++++++++++------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/LibGit2Sharp/Core/FileHistory.cs b/LibGit2Sharp/Core/FileHistory.cs index 5c10a1a24..0eaeeb788 100644 --- a/LibGit2Sharp/Core/FileHistory.cs +++ b/LibGit2Sharp/Core/FileHistory.cs @@ -120,13 +120,8 @@ private static IEnumerable FullHistory(IRepository repo, string path, var currentPath = map.Keys.Count > 0 ? map[currentCommit] : path; var currentTreeEntry = currentCommit.Tree[currentPath]; - if (currentTreeEntry == null) - { - yield break; - } - var parentCount = currentCommit.Parents.Count(); - if (parentCount == 0) + if (parentCount == 0 && currentTreeEntry != null) { yield return new LogEntry { Path = currentPath, Commit = currentCommit }; } @@ -134,20 +129,18 @@ private static IEnumerable FullHistory(IRepository repo, string path, { DetermineParentPaths(repo, currentCommit, currentPath, map); - if (parentCount != 1) - { - continue; - } - - var parentCommit = currentCommit.Parents.Single(); - var parentPath = map[parentCommit]; - var parentTreeEntry = parentCommit.Tree[parentPath]; - - if (parentTreeEntry == null || - parentTreeEntry.Target.Id != currentTreeEntry.Target.Id || - parentPath != currentPath) - { - yield return new LogEntry { Path = currentPath, Commit = currentCommit }; + foreach(var parentCommit in currentCommit.Parents) + { + var parentPath = map[parentCommit]; + var parentTreeEntry = parentCommit.Tree[parentPath]; + + if (currentTreeEntry != null && + (parentTreeEntry == null || + parentTreeEntry.Target.Id != currentTreeEntry.Target.Id || + parentPath != currentPath)) + { + yield return new LogEntry { Path = currentPath, Commit = currentCommit }; + } } } }