diff options
author | Kevin Sawicki <kevin@github.com> | 2011-11-22 16:29:28 -0800 |
---|---|---|
committer | Kevin Sawicki <kevin@github.com> | 2011-11-22 16:29:28 -0800 |
commit | c3fe50bb18ed4e4e5e563172be4076fa5901a18a (patch) | |
tree | a9f1013f7efc1ffbf49453a42749768cc4f91a0c /org.eclipse.jgit | |
parent | 900bdbac5bad9d40df8d310a8f319ab616d1420b (diff) | |
download | jgit-c3fe50bb18ed4e4e5e563172be4076fa5901a18a.tar.gz jgit-c3fe50bb18ed4e4e5e563172be4076fa5901a18a.zip |
Guard against null branch in PullCommand
Throw a NoHeadException when Repository.getFullBranch
returns null
Bug: 351543
Change-Id: I666cd5b67781508a293ae553c6fe5c080c8f4d99
Signed-off-by: Kevin Sawicki <kevin@github.com>
Diffstat (limited to 'org.eclipse.jgit')
3 files changed, 7 insertions, 1 deletions
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties index a5fea35ab7..fc32069999 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties @@ -352,6 +352,7 @@ prefixRemote=remote: problemWithResolvingPushRefSpecsLocally=Problem with resolving push ref specs locally: {0} progressMonUploading=Uploading {0} propertyIsAlreadyNonNull=Property is already non null +pullOnRepoWithoutHEADCurrentlyNotSupported=Pull on repository without HEAD currently not supported pullTaskName=Pull pushCancelled=push cancelled pushIsNotSupportedForBundleTransport=Push is not supported for bundle transport diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java index fcc6cafd5e..4dabe07412 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java @@ -412,6 +412,7 @@ public class JGitText extends TranslationBundle { /***/ public String problemWithResolvingPushRefSpecsLocally; /***/ public String progressMonUploading; /***/ public String propertyIsAlreadyNonNull; + /***/ public String pullOnRepoWithoutHEADCurrentlyNotSupported; /***/ public String pullTaskName; /***/ public String pushCancelled; /***/ public String pushIsNotSupportedForBundleTransport; 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 67f9832fb6..9aa33ddf68 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PullCommand.java @@ -112,7 +112,8 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> { */ public PullResult call() throws WrongRepositoryStateException, InvalidConfigurationException, DetachedHeadException, - InvalidRemoteException, CanceledException, RefNotFoundException { + InvalidRemoteException, CanceledException, RefNotFoundException, + NoHeadException { checkCallable(); monitor.beginTask(JGitText.get().pullTaskName, 2); @@ -120,6 +121,9 @@ public class PullCommand extends TransportCommand<PullCommand, PullResult> { String branchName; try { String fullBranch = repo.getFullBranch(); + if (fullBranch == null) + throw new NoHeadException( + JGitText.get().pullOnRepoWithoutHEADCurrentlyNotSupported); if (!fullBranch.startsWith(Constants.R_HEADS)) { // we can not pull if HEAD is detached and branch is not // specified explicitly |