diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java index d9fa393c7..683d1cd6e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java @@ -1718,6 +1718,7 @@ public class PackWriter implements AutoCloseable { final int maxBases = config.getDeltaSearchWindowSize(); Set baseTrees = new HashSet(); BlockList commits = new BlockList(); + Set roots = new HashSet<>(); RevCommit c; while ((c = walker.next()) != null) { if (exclude(c)) @@ -1729,8 +1730,12 @@ public class PackWriter implements AutoCloseable { } commits.add(c); + if (c.getParentCount() == 0) { + roots.add(c.copy()); + } countingMonitor.update(1); } + stats.rootCommits = Collections.unmodifiableSet(roots); if (shallowPack) { for (RevCommit cmit : commits) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java index 24efb943c..a811fe3cd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java @@ -178,6 +178,9 @@ public class PackStatistics { /** The collection of reused packs in the upload. */ public List reusedPacks; + /** Commits with no parents. */ + public Set rootCommits; + /** If a shallow pack, the depth in commits. */ public int depth; @@ -299,6 +302,11 @@ public class PackStatistics { return statistics.reusedPacks; } + /** @return unmodifiable collection of the root commits of the history. */ + public Set getRootCommits() { + return statistics.rootCommits; + } + /** * @return number of objects in the output pack that went through the delta * search process in order to find a potential delta base.