summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java12
2 files changed, 15 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java
index 6cbcd06735..7923fd49be 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java
@@ -52,6 +52,7 @@ import java.util.List;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidRefNameException;
import org.eclipse.jgit.api.errors.JGitInternalException;
+import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.errors.LockFailedException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.file.ReflogWriter;
@@ -184,6 +185,10 @@ public class StashDropCommand extends GitCommand<ObjectId> {
List<ReflogEntry> entries;
try {
ReflogReader reader = repo.getReflogReader(R_STASH);
+ if (reader == null) {
+ throw new RefNotFoundException(MessageFormat
+ .format(JGitText.get().refNotResolved, stashRef));
+ }
entries = reader.getReverseEntries();
} catch (IOException e) {
throw new JGitInternalException(JGitText.get().stashDropFailed, e);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
index fa28763f0d..fc7dca2d43 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
@@ -751,8 +751,11 @@ public abstract class Repository implements AutoCloseable {
private String resolveReflogCheckout(int checkoutNo)
throws IOException {
- List<ReflogEntry> reflogEntries = getReflogReader(Constants.HEAD)
- .getReverseEntries();
+ ReflogReader reader = getReflogReader(Constants.HEAD);
+ if (reader == null) {
+ return null;
+ }
+ List<ReflogEntry> reflogEntries = reader.getReverseEntries();
for (ReflogEntry entry : reflogEntries) {
CheckoutEntry checkout = entry.parseCheckout();
if (checkout != null)
@@ -773,6 +776,11 @@ public abstract class Repository implements AutoCloseable {
}
assert number >= 0;
ReflogReader reader = getReflogReader(ref.getName());
+ if (reader == null) {
+ throw new RevisionSyntaxException(
+ MessageFormat.format(JGitText.get().reflogEntryNotFound,
+ Integer.valueOf(number), ref.getName()));
+ }
ReflogEntry entry = reader.getReverseEntry(number);
if (entry == null)
throw new RevisionSyntaxException(MessageFormat.format(