}
Ref headRef = repo.getRef(Constants.HEAD);
- String refLogMessage = "checkout: moving from "
- + headRef.getTarget().getName();
+ String shortHeadRef = getShortBranchName(headRef);
+ String refLogMessage = "checkout: moving from " + shortHeadRef;
ObjectId branch = repo.resolve(name);
if (branch == null)
throw new RefNotFoundException(MessageFormat.format(JGitText
Ref ref = repo.getRef(name);
if (ref != null && !ref.getName().startsWith(Constants.R_HEADS))
ref = null;
+ String toName = Repository.shortenRefName(name);
RefUpdate refUpdate = repo.updateRef(Constants.HEAD, ref == null);
refUpdate.setForceUpdate(force);
- refUpdate.setRefLogMessage(refLogMessage + " to "
- + newCommit.getName(), false);
+ refUpdate.setRefLogMessage(refLogMessage + " to " + toName, false);
Result updateResult;
if (ref != null)
updateResult = refUpdate.link(ref.getName());
}
}
+ private String getShortBranchName(Ref headRef) {
+ if (headRef.getTarget().getName().equals(headRef.getName()))
+ return headRef.getTarget().getObjectId().getName();
+ return Repository.shortenRefName(headRef.getTarget().getName());
+ }
+
/**
* @param path
* Path to update in the working tree and index.