|
|
@ -223,7 +223,7 @@ public class CheckoutCommand extends GitCommand<Ref> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Ref headRef = repo.getRef(Constants.HEAD); |
|
|
|
Ref headRef = repo.exactRef(Constants.HEAD); |
|
|
|
if (headRef == null) { |
|
|
|
if (headRef == null) { |
|
|
|
// TODO Git CLI supports checkout from unborn branch, we should
|
|
|
|
// TODO Git CLI supports checkout from unborn branch, we should
|
|
|
|
// also allow this
|
|
|
|
// also allow this
|
|
|
@ -242,7 +242,7 @@ public class CheckoutCommand extends GitCommand<Ref> { |
|
|
|
JGitText.get().checkoutUnexpectedResult, |
|
|
|
JGitText.get().checkoutUnexpectedResult, |
|
|
|
r.name())); |
|
|
|
r.name())); |
|
|
|
this.status = CheckoutResult.NOT_TRIED_RESULT; |
|
|
|
this.status = CheckoutResult.NOT_TRIED_RESULT; |
|
|
|
return repo.getRef(Constants.HEAD); |
|
|
|
return repo.exactRef(Constants.HEAD); |
|
|
|
} |
|
|
|
} |
|
|
|
branch = getStartPointObjectId(); |
|
|
|
branch = getStartPointObjectId(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -277,7 +277,7 @@ public class CheckoutCommand extends GitCommand<Ref> { |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
dc.unlock(); |
|
|
|
dc.unlock(); |
|
|
|
} |
|
|
|
} |
|
|
|
Ref ref = repo.getRef(name); |
|
|
|
Ref ref = repo.findRef(name); |
|
|
|
if (ref != null && !ref.getName().startsWith(Constants.R_HEADS)) |
|
|
|
if (ref != null && !ref.getName().startsWith(Constants.R_HEADS)) |
|
|
|
ref = null; |
|
|
|
ref = null; |
|
|
|
String toName = Repository.shortenRefName(name); |
|
|
|
String toName = Repository.shortenRefName(name); |
|
|
@ -289,7 +289,7 @@ public class CheckoutCommand extends GitCommand<Ref> { |
|
|
|
updateResult = refUpdate.link(ref.getName()); |
|
|
|
updateResult = refUpdate.link(ref.getName()); |
|
|
|
else if (orphan) { |
|
|
|
else if (orphan) { |
|
|
|
updateResult = refUpdate.link(getBranchName()); |
|
|
|
updateResult = refUpdate.link(getBranchName()); |
|
|
|
ref = repo.getRef(Constants.HEAD); |
|
|
|
ref = repo.exactRef(Constants.HEAD); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
refUpdate.setNewObjectId(newCommit); |
|
|
|
refUpdate.setNewObjectId(newCommit); |
|
|
|
updateResult = refUpdate.forceUpdate(); |
|
|
|
updateResult = refUpdate.forceUpdate(); |
|
|
@ -519,7 +519,7 @@ public class CheckoutCommand extends GitCommand<Ref> { |
|
|
|
.get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
|
|
|
|
.get().branchNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
|
|
if (orphan) { |
|
|
|
if (orphan) { |
|
|
|
Ref refToCheck = repo.getRef(getBranchName()); |
|
|
|
Ref refToCheck = repo.exactRef(getBranchName()); |
|
|
|
if (refToCheck != null) |
|
|
|
if (refToCheck != null) |
|
|
|
throw new RefAlreadyExistsException(MessageFormat.format( |
|
|
|
throw new RefAlreadyExistsException(MessageFormat.format( |
|
|
|
JGitText.get().refAlreadyExists, name)); |
|
|
|
JGitText.get().refAlreadyExists, name)); |
|
|
|