Replace use of deprecated method Repository.getRef()

Change-Id: Iecf2b8deafc4991cc3333702fb9fa0638be7b914
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2016-05-20 11:28:21 +02:00
parent bfebe6ae4b
commit 4c236ff4bb
35 changed files with 58 additions and 58 deletions

View File

@ -406,7 +406,7 @@ protected RevCommit commitFile(String filename, String contents, String branch)
String originalBranch = repo.getFullBranch(); String originalBranch = repo.getFullBranch();
boolean empty = repo.resolve(Constants.HEAD) == null; boolean empty = repo.resolve(Constants.HEAD) == null;
if (!empty) { if (!empty) {
if (repo.getRef(branch) == null) if (repo.findRef(branch) == null)
git.branchCreate().setName(branch).call(); git.branchCreate().setName(branch).call();
git.checkout().setName(branch).call(); git.checkout().setName(branch).call();
} }

View File

@ -501,7 +501,7 @@ public RevCommit update(String ref, CommitBuilder to) throws Exception {
*/ */
public CommitBuilder amendRef(String ref) throws Exception { public CommitBuilder amendRef(String ref) throws Exception {
String name = normalizeRef(ref); String name = normalizeRef(ref);
Ref r = db.getRef(name); Ref r = db.exactRef(name);
if (r == null) if (r == null)
throw new IOException("Not a ref: " + ref); throw new IOException("Not a ref: " + ref);
return amend(pool.parseCommit(r.getObjectId()), branch(name).commit()); return amend(pool.parseCommit(r.getObjectId()), branch(name).commit());
@ -703,7 +703,7 @@ public RevCommit cherryPick(AnyObjectId id) throws Exception {
RevCommit parent = commit.getParent(0); RevCommit parent = commit.getParent(0);
pool.parseHeaders(parent); pool.parseHeaders(parent);
Ref headRef = db.getRef(Constants.HEAD); Ref headRef = db.exactRef(Constants.HEAD);
if (headRef == null) if (headRef == null)
throw new IOException("Missing HEAD"); throw new IOException("Missing HEAD");
RevCommit head = pool.parseCommit(headRef.getObjectId()); RevCommit head = pool.parseCommit(headRef.getObjectId());
@ -1025,7 +1025,7 @@ public class CommitBuilder {
CommitBuilder(BranchBuilder b) throws Exception { CommitBuilder(BranchBuilder b) throws Exception {
branch = b; branch = b;
Ref ref = db.getRef(branch.ref); Ref ref = db.exactRef(branch.ref);
if (ref != null && ref.getObjectId() != null) if (ref != null && ref.getObjectId() != null)
parent(pool.parseCommit(ref.getObjectId())); parent(pool.parseCommit(ref.getObjectId()));
} }

View File

@ -169,7 +169,7 @@ protected void run() throws Exception {
if (rename) { if (rename) {
String src, dst; String src, dst;
if (otherBranch == null) { if (otherBranch == null) {
final Ref head = db.getRef(Constants.HEAD); final Ref head = db.exactRef(Constants.HEAD);
if (head != null && head.isSymbolic()) { if (head != null && head.isSymbolic()) {
src = head.getLeaf().getName(); src = head.getLeaf().getName();
} else { } else {
@ -178,7 +178,7 @@ protected void run() throws Exception {
dst = branch; dst = branch;
} else { } else {
src = branch; src = branch;
final Ref old = db.getRef(src); final Ref old = db.findRef(src);
if (old == null) if (old == null)
throw die(MessageFormat.format(CLIText.get().doesNotExist, src)); throw die(MessageFormat.format(CLIText.get().doesNotExist, src));
if (!old.getName().startsWith(Constants.R_HEADS)) if (!old.getName().startsWith(Constants.R_HEADS))
@ -204,7 +204,7 @@ protected void run() throws Exception {
} else { } else {
startBranch = Constants.HEAD; startBranch = Constants.HEAD;
} }
Ref startRef = db.getRef(startBranch); Ref startRef = db.findRef(startBranch);
ObjectId startAt = db.resolve(startBranch + "^0"); //$NON-NLS-1$ ObjectId startAt = db.resolve(startBranch + "^0"); //$NON-NLS-1$
if (startRef != null) { if (startRef != null) {
startBranch = startRef.getName(); startBranch = startRef.getName();
@ -243,7 +243,7 @@ protected void run() throws Exception {
} }
private void list() throws Exception { private void list() throws Exception {
Ref head = db.getRef(Constants.HEAD); Ref head = db.exactRef(Constants.HEAD);
// This can happen if HEAD is stillborn // This can happen if HEAD is stillborn
if (head != null) { if (head != null) {
String current = head.getLeaf().getName(); String current = head.getLeaf().getName();

View File

@ -95,7 +95,7 @@ protected void run() throws NoHeadException, NoMessageException,
commitCmd.setOnly(p); commitCmd.setOnly(p);
commitCmd.setAmend(amend); commitCmd.setAmend(amend);
commitCmd.setAll(all); commitCmd.setAll(all);
Ref head = db.getRef(Constants.HEAD); Ref head = db.exactRef(Constants.HEAD);
if (head == null) { if (head == null) {
throw die(CLIText.get().onBranchToBeBorn); throw die(CLIText.get().onBranchToBeBorn);
} }

View File

@ -228,7 +228,7 @@ protected void run() throws Exception {
} }
private void addNoteMap(String notesRef) throws IOException { private void addNoteMap(String notesRef) throws IOException {
Ref notes = db.getRef(notesRef); Ref notes = db.exactRef(notesRef);
if (notes == null) if (notes == null)
return; return;
RevCommit notesCommit = argWalk.parseCommit(notes.getObjectId()); RevCommit notesCommit = argWalk.parseCommit(notes.getObjectId());

View File

@ -114,7 +114,7 @@ protected void run() throws Exception {
} }
// determine the other revision we want to merge with HEAD // determine the other revision we want to merge with HEAD
final Ref srcRef = db.getRef(ref); final Ref srcRef = db.findRef(ref);
final ObjectId src = db.resolve(ref + "^{commit}"); //$NON-NLS-1$ final ObjectId src = db.resolve(ref + "^{commit}"); //$NON-NLS-1$
if (src == null) if (src == null)
throw die(MessageFormat.format( throw die(MessageFormat.format(
@ -209,7 +209,7 @@ protected void run() throws Exception {
} }
private Ref getOldHead() throws IOException { private Ref getOldHead() throws IOException {
Ref oldHead = db.getRef(Constants.HEAD); Ref oldHead = db.exactRef(Constants.HEAD);
if (oldHead == null) { if (oldHead == null) {
throw die(CLIText.get().onBranchToBeBorn); throw die(CLIText.get().onBranchToBeBorn);
} }

View File

@ -204,7 +204,7 @@ private void printPorcelainLine(char x, char y, String path)
private void printLongStatus(org.eclipse.jgit.api.Status status) private void printLongStatus(org.eclipse.jgit.api.Status status)
throws IOException { throws IOException {
// Print current branch name // Print current branch name
final Ref head = db.getRef(Constants.HEAD); final Ref head = db.exactRef(Constants.HEAD);
if (head != null && head.isSymbolic()) { if (head != null && head.isSymbolic()) {
String branch = Repository.shortenRefName(head.getLeaf().getName()); String branch = Repository.shortenRefName(head.getLeaf().getName());
outw.println(CLIText.formatLine(MessageFormat.format( outw.println(CLIText.formatLine(MessageFormat.format(

View File

@ -596,7 +596,7 @@ private boolean inIndex(String path) throws IOException {
* @throws IOException * @throws IOException
*/ */
private void assertSameAsHead(Ref ref) throws IOException { private void assertSameAsHead(Ref ref) throws IOException {
Ref headRef = db.getRef(Constants.HEAD); Ref headRef = db.exactRef(Constants.HEAD);
assertEquals(headRef.getName(), ref.getName()); assertEquals(headRef.getName(), ref.getName());
assertEquals(headRef.getObjectId(), ref.getObjectId()); assertEquals(headRef.getObjectId(), ref.getObjectId());
} }

View File

@ -87,7 +87,7 @@ public Note call() throws GitAPIException {
RevCommit notesCommit = null; RevCommit notesCommit = null;
try (RevWalk walk = new RevWalk(repo); try (RevWalk walk = new RevWalk(repo);
ObjectInserter inserter = repo.newObjectInserter()) { ObjectInserter inserter = repo.newObjectInserter()) {
Ref ref = repo.getRef(notesRef); Ref ref = repo.findRef(notesRef);
// if we have a notes ref, use it // if we have a notes ref, use it
if (ref != null) { if (ref != null) {
notesCommit = walk.parseCommit(ref.getObjectId()); notesCommit = walk.parseCommit(ref.getObjectId());

View File

@ -223,7 +223,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException,
} }
} }
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 Ref call() throws GitAPIException, RefAlreadyExistsException,
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 Ref call() throws GitAPIException, RefAlreadyExistsException,
} 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 Ref call() throws GitAPIException, RefAlreadyExistsException,
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 @@ private void processOptions() throws InvalidRefNameException,
.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));

View File

@ -126,7 +126,7 @@ public CherryPickResult call() throws GitAPIException, NoMessageException,
try (RevWalk revWalk = new RevWalk(repo)) { try (RevWalk revWalk = new RevWalk(repo)) {
// get the head commit // get the head commit
Ref headRef = repo.getRef(Constants.HEAD); Ref headRef = repo.exactRef(Constants.HEAD);
if (headRef == null) if (headRef == null)
throw new NoHeadException( throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);

View File

@ -195,7 +195,7 @@ public RevCommit call() throws GitAPIException, NoHeadException,
} }
} }
Ref head = repo.getRef(Constants.HEAD); Ref head = repo.exactRef(Constants.HEAD);
if (head == null) if (head == null)
throw new NoHeadException( throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);

View File

@ -125,7 +125,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException,
checkCallable(); checkCallable();
processOptions(); processOptions();
try (RevWalk revWalk = new RevWalk(repo)) { try (RevWalk revWalk = new RevWalk(repo)) {
Ref refToCheck = repo.getRef(name); Ref refToCheck = repo.findRef(name);
boolean exists = refToCheck != null boolean exists = refToCheck != null
&& refToCheck.getName().startsWith(Constants.R_HEADS); && refToCheck.getName().startsWith(Constants.R_HEADS);
if (!force && exists) if (!force && exists)
@ -135,7 +135,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException,
ObjectId startAt = getStartPointObjectId(); ObjectId startAt = getStartPointObjectId();
String startPointFullName = null; String startPointFullName = null;
if (startPoint != null) { if (startPoint != null) {
Ref baseRef = repo.getRef(startPoint); Ref baseRef = repo.findRef(startPoint);
if (baseRef != null) if (baseRef != null)
startPointFullName = baseRef.getName(); startPointFullName = baseRef.getName();
} }
@ -207,7 +207,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException,
.get().createBranchUnexpectedResult, updateResult .get().createBranchUnexpectedResult, updateResult
.name())); .name()));
Ref result = repo.getRef(name); Ref result = repo.findRef(name);
if (result == null) if (result == null)
throw new JGitInternalException( throw new JGitInternalException(
JGitText.get().createBranchFailedUnknownReason); JGitText.get().createBranchFailedUnknownReason);

View File

@ -114,7 +114,7 @@ public List<String> call() throws GitAPIException,
for (String branchName : branchNames) { for (String branchName : branchNames) {
if (branchName == null) if (branchName == null)
continue; continue;
Ref currentRef = repo.getRef(branchName); Ref currentRef = repo.findRef(branchName);
if (currentRef == null) if (currentRef == null)
continue; continue;
@ -130,7 +130,7 @@ public List<String> call() throws GitAPIException,
for (String branchName : branchNames) { for (String branchName : branchNames) {
if (branchName == null) if (branchName == null)
continue; continue;
Ref currentRef = repo.getRef(branchName); Ref currentRef = repo.findRef(branchName);
if (currentRef == null) if (currentRef == null)
continue; continue;
String fullName = currentRef.getName(); String fullName = currentRef.getName();

View File

@ -90,7 +90,7 @@ public List<String> call() throws GitAPIException {
for (String tagName : tags) { for (String tagName : tags) {
if (tagName == null) if (tagName == null)
continue; continue;
Ref currentRef = repo.getRef(tagName); Ref currentRef = repo.findRef(tagName);
if (currentRef == null) if (currentRef == null)
continue; continue;
String fullName = currentRef.getName(); String fullName = currentRef.getName();

View File

@ -108,7 +108,7 @@ public List<Ref> call() throws GitAPIException {
Collection<Ref> refs = new ArrayList<Ref>(); Collection<Ref> refs = new ArrayList<Ref>();
// Also return HEAD if it's detached // Also return HEAD if it's detached
Ref head = repo.getRef(Constants.HEAD); Ref head = repo.exactRef(Constants.HEAD);
if (head != null && head.getLeaf().getName().equals(Constants.HEAD)) if (head != null && head.getLeaf().getName().equals(Constants.HEAD))
refs.add(head); refs.add(head);

View File

@ -82,7 +82,7 @@ public List<Note> call() throws GitAPIException {
List<Note> notes = new ArrayList<Note>(); List<Note> notes = new ArrayList<Note>();
NoteMap map = NoteMap.newEmptyMap(); NoteMap map = NoteMap.newEmptyMap();
try (RevWalk walk = new RevWalk(repo)) { try (RevWalk walk = new RevWalk(repo)) {
Ref ref = repo.getRef(notesRef); Ref ref = repo.findRef(notesRef);
// if we have a notes ref, use it // if we have a notes ref, use it
if (ref != null) { if (ref != null) {
RevCommit notesCommit = walk.parseCommit(ref.getObjectId()); RevCommit notesCommit = walk.parseCommit(ref.getObjectId());

View File

@ -231,7 +231,7 @@ public MergeResult call() throws GitAPIException, NoHeadException,
RevWalk revWalk = null; RevWalk revWalk = null;
DirCacheCheckout dco = null; DirCacheCheckout dco = null;
try { try {
Ref head = repo.getRef(Constants.HEAD); Ref head = repo.exactRef(Constants.HEAD);
if (head == null) if (head == null)
throw new NoHeadException( throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);

View File

@ -131,7 +131,7 @@ public Iterable<PushResult> call() throws GitAPIException,
refSpecs.addAll(config.getPushRefSpecs()); refSpecs.addAll(config.getPushRefSpecs());
} }
if (refSpecs.isEmpty()) { if (refSpecs.isEmpty()) {
Ref head = repo.getRef(Constants.HEAD); Ref head = repo.exactRef(Constants.HEAD);
if (head != null && head.isSymbolic()) if (head != null && head.isSymbolic())
refSpecs.add(new RefSpec(head.getLeaf().getName())); refSpecs.add(new RefSpec(head.getLeaf().getName()));
} }
@ -348,7 +348,7 @@ public PushCommand add(String nameOrSpec) {
} else { } else {
Ref src; Ref src;
try { try {
src = repo.getRef(nameOrSpec); src = repo.findRef(nameOrSpec);
} catch (IOException e) { } catch (IOException e) {
throw new JGitInternalException( throw new JGitInternalException(
JGitText.get().exceptionCaughtDuringExecutionOfPushCommand, JGitText.get().exceptionCaughtDuringExecutionOfPushCommand,

View File

@ -419,7 +419,7 @@ private boolean autoStashApply() throws IOException, GitAPIException {
private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent, private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent,
String refLogMessage) throws IOException { String refLogMessage) throws IOException {
Ref currentRef = repo.getRef(Constants.R_STASH); Ref currentRef = repo.exactRef(Constants.R_STASH);
RefUpdate refUpdate = repo.updateRef(Constants.R_STASH); RefUpdate refUpdate = repo.updateRef(Constants.R_STASH);
refUpdate.setNewObjectId(commitId); refUpdate.setNewObjectId(commitId);
refUpdate.setRefLogIdent(refLogIdent); refUpdate.setRefLogIdent(refLogIdent);
@ -750,7 +750,7 @@ private RevCommit doSquashFixup(boolean isSquash, RevCommit commitToPick,
private void resetSoftToParent() throws IOException, private void resetSoftToParent() throws IOException,
GitAPIException, CheckoutConflictException { GitAPIException, CheckoutConflictException {
Ref ref = repo.getRef(Constants.ORIG_HEAD); Ref ref = repo.exactRef(Constants.ORIG_HEAD);
ObjectId orig_head = ref == null ? null : ref.getObjectId(); ObjectId orig_head = ref == null ? null : ref.getObjectId();
try { try {
// we have already commited the cherry-picked commit. // we have already commited the cherry-picked commit.
@ -1207,7 +1207,7 @@ private static String getHeadName(Ref head) {
} }
private Ref getHead() throws IOException, RefNotFoundException { private Ref getHead() throws IOException, RefNotFoundException {
Ref head = repo.getRef(Constants.HEAD); Ref head = repo.exactRef(Constants.HEAD);
if (head == null || head.getObjectId() == null) if (head == null || head.getObjectId() == null)
throw new RefNotFoundException(MessageFormat.format( throw new RefNotFoundException(MessageFormat.format(
JGitText.get().refNotResolved, Constants.HEAD)); JGitText.get().refNotResolved, Constants.HEAD));

View File

@ -85,7 +85,7 @@ public Note call() throws GitAPIException {
ObjectInserter inserter = repo.newObjectInserter()) { ObjectInserter inserter = repo.newObjectInserter()) {
NoteMap map = NoteMap.newEmptyMap(); NoteMap map = NoteMap.newEmptyMap();
RevCommit notesCommit = null; RevCommit notesCommit = null;
Ref ref = repo.getRef(notesRef); Ref ref = repo.exactRef(notesRef);
// if we have a notes ref, use it // if we have a notes ref, use it
if (ref != null) { if (ref != null) {
notesCommit = walk.parseCommit(ref.getObjectId()); notesCommit = walk.parseCommit(ref.getObjectId());

View File

@ -107,11 +107,11 @@ public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameEx
try { try {
String fullOldName; String fullOldName;
String fullNewName; String fullNewName;
if (repo.getRef(newName) != null) if (repo.findRef(newName) != null)
throw new RefAlreadyExistsException(MessageFormat.format( throw new RefAlreadyExistsException(MessageFormat.format(
JGitText.get().refAlreadyExists1, newName)); JGitText.get().refAlreadyExists1, newName));
if (oldName != null) { if (oldName != null) {
Ref ref = repo.getRef(oldName); Ref ref = repo.findRef(oldName);
if (ref == null) if (ref == null)
throw new RefNotFoundException(MessageFormat.format( throw new RefNotFoundException(MessageFormat.format(
JGitText.get().refNotResolved, oldName)); JGitText.get().refNotResolved, oldName));
@ -186,7 +186,7 @@ public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameEx
repoConfig.save(); repoConfig.save();
} }
Ref resultRef = repo.getRef(newName); Ref resultRef = repo.findRef(newName);
if (resultRef == null) if (resultRef == null)
throw new JGitInternalException( throw new JGitInternalException(
JGitText.get().renameBranchFailedUnknownReason); JGitText.get().renameBranchFailedUnknownReason);

View File

@ -171,7 +171,7 @@ public Ref call() throws GitAPIException, CheckoutConflictException {
// reset [commit] -- paths // reset [commit] -- paths
resetIndexForPaths(commitTree); resetIndexForPaths(commitTree);
setCallable(false); setCallable(false);
return repo.getRef(Constants.HEAD); return repo.exactRef(Constants.HEAD);
} }
final Ref result; final Ref result;

View File

@ -129,7 +129,7 @@ public RevCommit call() throws NoMessageException, UnmergedPathsException,
try (RevWalk revWalk = new RevWalk(repo)) { try (RevWalk revWalk = new RevWalk(repo)) {
// get the head commit // get the head commit
Ref headRef = repo.getRef(Constants.HEAD); Ref headRef = repo.exactRef(Constants.HEAD);
if (headRef == null) if (headRef == null)
throw new NoHeadException( throw new NoHeadException(
JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);

View File

@ -79,7 +79,7 @@ public Note call() throws GitAPIException {
NoteMap map = NoteMap.newEmptyMap(); NoteMap map = NoteMap.newEmptyMap();
RevCommit notesCommit = null; RevCommit notesCommit = null;
try (RevWalk walk = new RevWalk(repo)) { try (RevWalk walk = new RevWalk(repo)) {
Ref ref = repo.getRef(notesRef); Ref ref = repo.exactRef(notesRef);
// if we have a notes ref, use it // if we have a notes ref, use it
if (ref != null) { if (ref != null) {
notesCommit = walk.parseCommit(ref.getObjectId()); notesCommit = walk.parseCommit(ref.getObjectId());

View File

@ -206,7 +206,7 @@ private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent,
String refLogMessage) throws IOException { String refLogMessage) throws IOException {
if (ref == null) if (ref == null)
return; return;
Ref currentRef = repo.getRef(ref); Ref currentRef = repo.findRef(ref);
RefUpdate refUpdate = repo.updateRef(ref); RefUpdate refUpdate = repo.updateRef(ref);
refUpdate.setNewObjectId(commitId); refUpdate.setNewObjectId(commitId);
refUpdate.setRefLogIdent(refLogIdent); refUpdate.setRefLogIdent(refLogIdent);
@ -220,7 +220,7 @@ private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent,
private Ref getHead() throws GitAPIException { private Ref getHead() throws GitAPIException {
try { try {
Ref head = repo.getRef(Constants.HEAD); Ref head = repo.exactRef(Constants.HEAD);
if (head == null || head.getObjectId() == null) if (head == null || head.getObjectId() == null)
throw new NoHeadException(JGitText.get().headRequiredToStash); throw new NoHeadException(JGitText.get().headRequiredToStash);
return head; return head;

View File

@ -118,7 +118,7 @@ public StashDropCommand setAll(final boolean all) {
private Ref getRef() throws GitAPIException { private Ref getRef() throws GitAPIException {
try { try {
return repo.getRef(R_STASH); return repo.exactRef(R_STASH);
} catch (IOException e) { } catch (IOException e) {
throw new InvalidRefNameException(MessageFormat.format( throw new InvalidRefNameException(MessageFormat.format(
JGitText.get().cannotRead, R_STASH), e); JGitText.get().cannotRead, R_STASH), e);
@ -236,7 +236,7 @@ public ObjectId call() throws GitAPIException {
updateRef(stashRef, entryId); updateRef(stashRef, entryId);
try { try {
Ref newStashRef = repo.getRef(R_STASH); Ref newStashRef = repo.exactRef(R_STASH);
return newStashRef != null ? newStashRef.getObjectId() : null; return newStashRef != null ? newStashRef.getObjectId() : null;
} catch (IOException e) { } catch (IOException e) {
throw new InvalidRefNameException(MessageFormat.format( throw new InvalidRefNameException(MessageFormat.format(

View File

@ -81,7 +81,7 @@ public Collection<RevCommit> call() throws GitAPIException,
checkCallable(); checkCallable();
try { try {
if (repo.getRef(Constants.R_STASH) == null) if (repo.exactRef(Constants.R_STASH) == null)
return Collections.emptyList(); return Collections.emptyList();
} catch (IOException e) { } catch (IOException e) {
throw new InvalidRefNameException(MessageFormat.format( throw new InvalidRefNameException(MessageFormat.format(

View File

@ -101,7 +101,7 @@ public SubmoduleSyncCommand addPath(final String path) {
* @throws IOException * @throws IOException
*/ */
protected String getHeadBranch(final Repository subRepo) throws IOException { protected String getHeadBranch(final Repository subRepo) throws IOException {
Ref head = subRepo.getRef(Constants.HEAD); Ref head = subRepo.exactRef(Constants.HEAD);
if (head != null && head.isSymbolic()) if (head != null && head.isSymbolic())
return Repository.shortenRefName(head.getLeaf().getName()); return Repository.shortenRefName(head.getLeaf().getName());
else else

View File

@ -184,7 +184,7 @@ private Ref updateTagRef(ObjectId tagId, RevWalk revWalk,
switch (updateResult) { switch (updateResult) {
case NEW: case NEW:
case FORCED: case FORCED:
return repo.getRef(refName); return repo.exactRef(refName);
case LOCK_FAILURE: case LOCK_FAILURE:
throw new ConcurrentRefUpdateException( throw new ConcurrentRefUpdateException(
JGitText.get().couldNotLockHEAD, tagRef.getRef(), JGitText.get().couldNotLockHEAD, tagRef.getRef(),

View File

@ -491,7 +491,7 @@ public void notifyIndexChanged() {
* @throws IOException the ref could not be accessed. * @throws IOException the ref could not be accessed.
*/ */
public ReflogReader getReflogReader(String refName) throws IOException { public ReflogReader getReflogReader(String refName) throws IOException {
Ref ref = getRef(refName); Ref ref = findRef(refName);
if (ref != null) if (ref != null)
return new ReflogReaderImpl(this, ref.getName()); return new ReflogReaderImpl(this, ref.getName());
return null; return null;

View File

@ -79,11 +79,11 @@ public static BranchTrackingStatus of(Repository repository, String branchName)
if (trackingBranch == null) if (trackingBranch == null)
return null; return null;
Ref tracking = repository.getRef(trackingBranch); Ref tracking = repository.exactRef(trackingBranch);
if (tracking == null) if (tracking == null)
return null; return null;
Ref local = repository.getRef(fullBranchName); Ref local = repository.exactRef(fullBranchName);
if (local == null) if (local == null)
return null; return null;

View File

@ -898,7 +898,7 @@ public String toString() {
* This is essentially the same as doing: * This is essentially the same as doing:
* *
* <pre> * <pre>
* return getRef(Constants.HEAD).getTarget().getName() * return exactRef(Constants.HEAD).getTarget().getName()
* </pre> * </pre>
* *
* Except when HEAD is detached, in which case this method returns the * Except when HEAD is detached, in which case this method returns the
@ -912,7 +912,7 @@ public String toString() {
*/ */
@Nullable @Nullable
public String getFullBranch() throws IOException { public String getFullBranch() throws IOException {
Ref head = getRef(Constants.HEAD); Ref head = exactRef(Constants.HEAD);
if (head == null) { if (head == null) {
return null; return null;
} }

View File

@ -264,7 +264,7 @@ public static String getSubmoduleRemoteUrl(final Repository parent,
String remoteName = null; String remoteName = null;
// Look up remote URL associated wit HEAD ref // Look up remote URL associated wit HEAD ref
Ref ref = parent.getRef(Constants.HEAD); Ref ref = parent.exactRef(Constants.HEAD);
if (ref != null) { if (ref != null) {
if (ref.isSymbolic()) if (ref.isSymbolic())
ref = ref.getLeaf(); ref = ref.getLeaf();
@ -704,7 +704,7 @@ public String getHeadRef() throws IOException {
if (subRepo == null) if (subRepo == null)
return null; return null;
try { try {
Ref head = subRepo.getRef(Constants.HEAD); Ref head = subRepo.exactRef(Constants.HEAD);
return head != null ? head.getLeaf().getName() : null; return head != null ? head.getLeaf().getName() : null;
} finally { } finally {
subRepo.close(); subRepo.close();

View File

@ -629,7 +629,7 @@ public static Collection<RemoteRefUpdate> findRemoteRefUpdatesFor(
for (final RefSpec spec : procRefs) { for (final RefSpec spec : procRefs) {
String srcSpec = spec.getSource(); String srcSpec = spec.getSource();
final Ref srcRef = db.getRef(srcSpec); final Ref srcRef = db.findRef(srcSpec);
if (srcRef != null) if (srcRef != null)
srcSpec = srcRef.getName(); srcSpec = srcRef.getName();