Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHan-Wen Nienhuys2021-09-27 14:07:27 +0000
committerHan-Wen NIenhuys2021-09-27 15:30:13 +0000
commitb4782d74fdb8e730e06b2fb6c4285fcb4e38439f (patch)
treefc1779fdef2c3f69435e13b091b25e1e5b3d6c29 /org.eclipse.jgit/src/org
parent9c3190ce7a8ee036497b93cbb385e828bbc3d701 (diff)
downloadjgit-b4782d74fdb8e730e06b2fb6c4285fcb4e38439f.tar.gz
jgit-b4782d74fdb8e730e06b2fb6c4285fcb4e38439f.tar.xz
jgit-b4782d74fdb8e730e06b2fb6c4285fcb4e38439f.zip
reftable: pass on invalid object ID in conversion
Before, while trying to determine if an object ID was a tag or not, the reftable conversion would yield an exception. Change-Id: I3688a0ffa9e774ba27f320e3840ff8cada21ecf0
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java
index c0dc625d99..e5ffd77c5d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java
@@ -59,6 +59,7 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.events.RefsChangedEvent;
import org.eclipse.jgit.internal.storage.reftable.MergedReftable;
import org.eclipse.jgit.internal.storage.reftable.ReftableBatchRefUpdate;
@@ -615,15 +616,20 @@ public class FileReftableDatabase extends RefDatabase {
r.getTarget().getName(), null));
}
ObjectId newId = r.getObjectId();
- RevObject obj = rw.parseAny(newId);
RevObject peel = null;
- if (obj instanceof RevTag) {
- peel = rw.peel(obj);
+ try {
+ RevObject obj = rw.parseAny(newId);
+ if (obj instanceof RevTag) {
+ peel = rw.peel(obj);
+ }
+ } catch (MissingObjectException e) {
+ /* ignore this error and copy the dangling object ID into reftable too. */
}
if (peel != null) {
- return new ObjectIdRef.PeeledTag(PACKED, r.getName(), newId,
- peel.copy());
- }
+ return new ObjectIdRef.PeeledTag(PACKED, r.getName(), newId,
+ peel.copy());
+ }
+
return new ObjectIdRef.PeeledNonTag(PACKED, r.getName(), newId);
}

Back to the top