Don't use deprecated Repository#getAllRefs in Repository

Also expose the potentially IOException thrown by RefDatabase#getRefs.
Hence the following methods now potentially throw IOException:
- Repository#getAllRefsByPeeledObjectId

Bug: 534731
Change-Id: Id6956ff112560e6314d4335238494708346f2338
This commit is contained in:
Matthias Sohn 2021-06-23 10:29:21 +02:00
parent 403338e116
commit 0a3aaac33e
2 changed files with 6 additions and 4 deletions

View File

@ -1161,12 +1161,14 @@ public Ref peel(Ref ref) {
* 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)

View File

@ -121,7 +121,7 @@ public RevCommit next() throws MissingObjectException,
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