import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
import org.eclipse.jgit.api.MergeResult.MergeStatus;
+import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.lib.RefUpdate;
+import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryState;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.lib.StoredConfig;
.getRepositoryState());
}
+ @Test(expected = NoHeadException.class)
+ public void testPullEmptyRepository() throws Exception {
+ Repository empty = createWorkRepository();
+ RefUpdate delete = empty.updateRef(Constants.HEAD, true);
+ delete.setForceUpdate(true);
+ delete.delete();
+ Git.wrap(empty).pull().call();
+ }
+
@Override
@Before
public void setUp() throws Exception {
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
/***/ public String problemWithResolvingPushRefSpecsLocally;
/***/ public String progressMonUploading;
/***/ public String propertyIsAlreadyNonNull;
+ /***/ public String pullOnRepoWithoutHEADCurrentlyNotSupported;
/***/ public String pullTaskName;
/***/ public String pushCancelled;
/***/ public String pushIsNotSupportedForBundleTransport;
*/
public PullResult call() throws WrongRepositoryStateException,
InvalidConfigurationException, DetachedHeadException,
- InvalidRemoteException, CanceledException, RefNotFoundException {
+ InvalidRemoteException, CanceledException, RefNotFoundException,
+ NoHeadException {
checkCallable();
monitor.beginTask(JGitText.get().pullTaskName, 2);
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