]> source.dussan.org Git - jgit.git/commitdiff
Don't use deprecated Repository#getAllRefs in Repository 36/188136/1
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 23 Jun 2021 08:29:21 +0000 (10:29 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 25 Nov 2021 11:06:29 +0000 (12:06 +0100)
Also expose the potentially IOException thrown by RefDatabase#getRefs.
Hence the following methods now potentially throw IOException:
- Repository#getAllRefsByPeeledObjectId

Bug: 534731
Change-Id: Id6956ff112560e6314d4335238494708346f2338

org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
org.eclipse.jgit/src/org/eclipse/jgit/revplot/PlotWalk.java

index 2d1aca8de1898ca577bc874547644b34ed6b67bc..e594e528be1820442a3f402274db5896902439ee 100644 (file)
@@ -1161,12 +1161,14 @@ public abstract class Repository implements AutoCloseable {
         * Get a map with all objects referenced by a peeled ref.
         *
         * @return a map with all objects referenced by a peeled ref.
+        * @throws IOException
         */
        @NonNull
-       public Map<AnyObjectId, Set<Ref>> getAllRefsByPeeledObjectId() {
-               Map<String, Ref> allRefs = getAllRefs();
+       public Map<AnyObjectId, Set<Ref>> getAllRefsByPeeledObjectId()
+                       throws IOException {
+               List<Ref> allRefs = getRefDatabase().getRefs();
                Map<AnyObjectId, Set<Ref>> ret = new HashMap<>(allRefs.size());
-               for (Ref ref : allRefs.values()) {
+               for (Ref ref : allRefs) {
                        ref = peel(ref);
                        AnyObjectId target = ref.getPeeledObjectId();
                        if (target == null)
index b4ccfe0ae479a1af3da3804b37530267d012d6fe..058233865251c1dc550f84904adb0134e4f9475b 100644 (file)
@@ -121,7 +121,7 @@ public class PlotWalk extends RevWalk {
                return pc;
        }
 
-       private Ref[] getRefs(AnyObjectId commitId) {
+       private Ref[] getRefs(AnyObjectId commitId) throws IOException {
                if (reverseRefMap == null) {
                        reverseRefMap = repository.getAllRefsByPeeledObjectId();
                        for (Map.Entry<AnyObjectId, Set<Ref>> entry : additionalRefMap