From 8542bf790e156c0e9c0ab43648ca7f9f97a69836 Mon Sep 17 00:00:00 2001 From: Ronald Bhuleskar Date: Fri, 5 Aug 2022 17:30:55 -0700 Subject: [PATCH] Provide default shallowCommits getter and setter in ObjectDatabase I649db9ae679ec2606cf7c530b040f8b6b93eb81a added a default implementation for getShallowCommits and setShallowCommits to DfsObjDatabase, for the convenience of any implementers that define subclasses. But we forgot that some implementers inherit from ObjectDatabase directly instead. Move the default getter and setter to the base class so that such callers do not need source changes to unbreak their build. This also lets us update the api_filters to reflect that this is no longer an API-breaking change. Change-Id: I5dcca462eb306e511e57907b7d9264d51b3f3014 --- org.eclipse.jgit/.settings/.api_filters | 14 -------------- .../internal/storage/dfs/DfsObjDatabase.java | 16 ---------------- .../org/eclipse/jgit/lib/ObjectDatabase.java | 17 +++++++++++++++-- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters index 4af7adc72..1c283e761 100644 --- a/org.eclipse.jgit/.settings/.api_filters +++ b/org.eclipse.jgit/.settings/.api_filters @@ -9,20 +9,6 @@ - - - - - - - - - - - - - - diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java index c50e03869..46ec87df5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java @@ -29,7 +29,6 @@ import org.eclipse.jgit.internal.storage.pack.PackExt; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.ObjectDatabase; -import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.ObjectReader; @@ -58,8 +57,6 @@ public void markDirty() { } }; - private static final Set shallowCommits = Collections.emptySet(); - /** * Sources for a pack file. *

@@ -507,19 +504,6 @@ protected abstract ReadableChannel openFile( protected abstract DfsOutputStream writeFile( DfsPackDescription desc, PackExt ext) throws IOException; - @Override - public Set getShallowCommits() throws IOException { - return shallowCommits; - } - - @Override - public void setShallowCommits(Set shallowCommits) { - if (!shallowCommits.isEmpty()) { - throw new UnsupportedOperationException( - "Shallow commits expected to be empty."); - } - } - void addPack(DfsPackFile newPack) throws IOException { PackList o, n; do { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java index 1c0f43609..a39766cbd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDatabase.java @@ -11,6 +11,7 @@ package org.eclipse.jgit.lib; import java.io.IOException; +import java.util.Collections; import java.util.Set; import org.eclipse.jgit.errors.IncorrectObjectTypeException; @@ -23,6 +24,9 @@ * {@link org.eclipse.jgit.lib.ObjectId}. */ public abstract class ObjectDatabase implements AutoCloseable { + + private static final Set shallowCommits = Collections.emptySet(); + /** * Initialize a new database instance for access. */ @@ -79,7 +83,10 @@ public void create() throws IOException { * * @since 6.3 */ - public abstract Set getShallowCommits() throws IOException; + public Set getShallowCommits() throws IOException { + return shallowCommits; + } + /** * Update the shallow commits of the current repository @@ -90,7 +97,13 @@ public void create() throws IOException { * * @since 6.3 */ - public abstract void setShallowCommits(Set shallowCommits) throws IOException; + public void setShallowCommits(Set shallowCommits) + throws IOException { + if (!shallowCommits.isEmpty()) { + throw new UnsupportedOperationException( + "Shallow commits expected to be empty."); //$NON-NLS-1$ + } + } /** * Close any resources held by this database.