diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-06-23 10:38:50 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-10-23 07:31:08 -0400 |
commit | 4b4a95b1bbd910976bf872b18ac6cab5944d531c (patch) | |
tree | 9d923b02e2c5e5225bc7556d17a916db42ca092a /org.eclipse.jgit | |
parent | 3b960ae72daa76d0d8f85c8a0d74575af0c48b24 (diff) | |
download | jgit-4b4a95b1bbd910976bf872b18ac6cab5944d531c.tar.gz jgit-4b4a95b1bbd910976bf872b18ac6cab5944d531c.zip |
Remove use of deprecated getAllRefs() in UploadPack
Repository.getAllRefs() is deprecated and should not
be used anymore.
Bug: 534731
Change-Id: I037a9b901275bfa7952b4c79861d7639c9d42715
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index fa2448083f..6da6c13342 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -57,6 +57,7 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.TreeMap; +import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -406,14 +407,16 @@ public class UploadPack { * were advertised. */ public void setAdvertisedRefs(@Nullable Map<String, Ref> allRefs) { - if (allRefs != null) + if (allRefs != null) { refs = allRefs; - else - refs = db.getAllRefs(); - if (refFilter == RefFilter.DEFAULT) + } else { + refs = getAllRefs(); + } + if (refFilter == RefFilter.DEFAULT) { refs = transferConfig.getRefFilter().filter(refs); - else + } else { refs = refFilter.filter(refs); + } } /** @@ -864,6 +867,20 @@ public class UploadPack { return statistics; } + /** + * Extract the full list of refs from the ref-db. + * + * @return Map of all refname/ref + */ + private Map<String, Ref> getAllRefs() { + try { + return db.getRefDatabase().getRefs().stream().collect( + Collectors.toMap(Ref::getName, Function.identity())); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + private Map<String, Ref> getAdvertisedOrDefaultRefs() throws IOException { if (refs != null) { return refs; |