diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-07-01 14:13:19 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2021-07-01 14:13:19 -0400 |
commit | 23ae9f827c89f727969c778aceb3242c903b58f3 (patch) | |
tree | 09bbc41909b6e9f8fdf3df43bbc6d33010bed143 | |
parent | 0b9193e69fccdd4c9decb6a94400607d7484e6de (diff) | |
parent | ed5be35e2ef69b23260d4ec1ce3cabfc4aee0c95 (diff) | |
download | jgit-23ae9f827c89f727969c778aceb3242c903b58f3.tar.gz jgit-23ae9f827c89f727969c778aceb3242c903b58f3.zip |
Merge "Remove use of deprecated getAllRefs() in ReceivePack"
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java index 79f60c3202..58f8895e00 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -29,6 +29,7 @@ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; @@ -37,6 +38,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.function.Function; +import java.util.stream.Collectors; import org.eclipse.jgit.annotations.Nullable; import org.eclipse.jgit.errors.InvalidObjectIdException; @@ -441,7 +444,7 @@ public class ReceivePack { */ public void setAdvertisedRefs(Map<String, Ref> allRefs, Set<ObjectId> additionalHaves) { - refs = allRefs != null ? allRefs : db.getAllRefs(); + refs = allRefs != null ? allRefs : getAllRefs(); refs = refFilter.filter(refs); advertisedHaves.clear(); @@ -1296,6 +1299,21 @@ public class ReceivePack { } /** + * 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); + } + } + + /** * Receive a list of commands from the input. * * @throws java.io.IOException |