From 68064ed33929042e15749743e251c82e41871005 Mon Sep 17 00:00:00 2001 From: Stefan Lay Date: Wed, 16 Feb 2011 15:46:26 +0100 Subject: [PATCH] Fix NullPointer when pulling from a deleted local branch A checked Exception is thrown instead. The reason for throwing an Exception is that the state of the repository is inconsistent in this case: There is a merge configuration containing a non-existing local branch. Ideally the deletion of a local branch should also delete the corresponding merge configuration. Bug: 337315 Change-Id: I8ed57d5aaed60aaab685fc11a8695e474e60215f Signed-off-by: Stefan Lay Signed-off-by: Matthias Sohn --- org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java index f50567411..1c86bd663 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java @@ -138,7 +138,7 @@ public PullCommand setCredentialsProvider( */ public PullResult call() throws WrongRepositoryStateException, InvalidConfigurationException, DetachedHeadException, - InvalidRemoteException, CanceledException { + InvalidRemoteException, CanceledException, RefNotFoundException { checkCallable(); monitor.beginTask(JGitText.get().pullTaskName, 2); @@ -248,6 +248,9 @@ public PullResult call() throws WrongRepositoryStateException, } else { try { commitToMerge = repo.resolve(remoteBranchName); + if (commitToMerge == null) + throw new RefNotFoundException(MessageFormat.format( + JGitText.get().refNotResolved, remoteBranchName)); } catch (IOException e) { throw new JGitInternalException( JGitText.get().exceptionCaughtDuringExecutionOfPullCommand,