]> source.dussan.org Git - jgit.git/commitdiff
Fix NullPointer when pulling from a deleted local branch 46/2546/1
authorStefan Lay <stefan.lay@sap.com>
Wed, 16 Feb 2011 14:46:26 +0000 (15:46 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Feb 2011 23:54:02 +0000 (00:54 +0100)
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 <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java

index f505674117f7c0ff331b155b6a9609387bab1ba4..1c86bd6638acbe7e93545a94d988160d42200630 100644 (file)
@@ -138,7 +138,7 @@ public class PullCommand extends GitCommand<PullResult> {
         */
        public PullResult call() throws WrongRepositoryStateException,
                        InvalidConfigurationException, DetachedHeadException,
-                       InvalidRemoteException, CanceledException {
+                       InvalidRemoteException, CanceledException, RefNotFoundException {
                checkCallable();
 
                monitor.beginTask(JGitText.get().pullTaskName, 2);
@@ -248,6 +248,9 @@ public class PullCommand extends GitCommand<PullResult> {
                } 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,