From de78cf33672813feecce36637694b189f1c10082 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 30 Jul 2010 17:50:58 -0700 Subject: [PATCH] Export the ObjectId on MissingObjectException Callers catching a MissingObjectException may need programmatic access to the ObjectId that wasn't available in the repository. Change-Id: I2be0380251ebe7e4921fa74e246724e48ad88b0e Signed-off-by: Shawn O. Pearce --- .../org/eclipse/jgit/errors/MissingObjectException.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.java index 1d193e18c7..1807a6cfc5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/MissingObjectException.java @@ -59,6 +59,8 @@ import org.eclipse.jgit.lib.ObjectId; public class MissingObjectException extends IOException { private static final long serialVersionUID = 1L; + private final ObjectId missing; + /** * Construct a MissingObjectException for the specified object id. * Expected type is reported to simplify tracking down the problem. @@ -68,6 +70,7 @@ public class MissingObjectException extends IOException { */ public MissingObjectException(final ObjectId id, final String type) { super(MessageFormat.format(JGitText.get().missingObject, type, id.name())); + missing = id.copy(); } /** @@ -80,4 +83,9 @@ public class MissingObjectException extends IOException { public MissingObjectException(final ObjectId id, final int type) { this(id, Constants.typeString(type)); } + + /** @return the ObjectId that was not found. */ + public ObjectId getObjectId() { + return missing; + } } -- 2.39.5