summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2015-08-16 14:10:16 -0700
committerShawn Pearce <spearce@spearce.org>2015-08-16 14:10:16 -0700
commit1d7d0f95e0be8121ee16640fa1cd3b0805fd9092 (patch)
treea45b0a7f5b9d8a29527d88b0b7862c84d9b64cc6
parentf9bd6c1239b9e66bfd74e5a2462621a5f5fa641c (diff)
downloadjgit-1d7d0f95e0be8121ee16640fa1cd3b0805fd9092.tar.gz
jgit-1d7d0f95e0be8121ee16640fa1cd3b0805fd9092.zip
Expose the set of root commits in PackStatistics
Root commits are commits with zero parents. If a commmit has no parents it is the first commit in the repository. In general the root commits should be unique for any given project, as the first commit will be created at a different time, by a different user with its own message. These root commits can be used as a "fingerprint" to identify disjoint histories. Change-Id: Id891dbc1f17c816cea404569578bb7635ff85cdb
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java8
2 files changed, 13 insertions, 0 deletions
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 d9fa393c7e..683d1cd6e9 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<RevTree> baseTrees = new HashSet<RevTree>();
BlockList<RevCommit> commits = new BlockList<RevCommit>();
+ Set<ObjectId> 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 24efb943c3..a811fe3cde 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<CachedPack> reusedPacks;
+ /** Commits with no parents. */
+ public Set<ObjectId> 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<ObjectId> 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.