From 4c236ff4bbf664fd177a33f42517b0eef52510c8 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Fri, 20 May 2016 11:28:21 +0200 Subject: [PATCH] Replace use of deprecated method Repository.getRef() Change-Id: Iecf2b8deafc4991cc3333702fb9fa0638be7b914 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/junit/RepositoryTestCase.java | 2 +- .../src/org/eclipse/jgit/junit/TestRepository.java | 6 +++--- .../src/org/eclipse/jgit/pgm/Branch.java | 8 ++++---- .../src/org/eclipse/jgit/pgm/Commit.java | 2 +- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java | 2 +- .../src/org/eclipse/jgit/pgm/Merge.java | 4 ++-- .../src/org/eclipse/jgit/pgm/Status.java | 2 +- .../tst/org/eclipse/jgit/api/ResetCommandTest.java | 2 +- .../src/org/eclipse/jgit/api/AddNoteCommand.java | 2 +- .../src/org/eclipse/jgit/api/CheckoutCommand.java | 10 +++++----- .../src/org/eclipse/jgit/api/CherryPickCommand.java | 2 +- .../src/org/eclipse/jgit/api/CommitCommand.java | 2 +- .../src/org/eclipse/jgit/api/CreateBranchCommand.java | 6 +++--- .../src/org/eclipse/jgit/api/DeleteBranchCommand.java | 4 ++-- .../src/org/eclipse/jgit/api/DeleteTagCommand.java | 2 +- .../src/org/eclipse/jgit/api/ListBranchCommand.java | 2 +- .../src/org/eclipse/jgit/api/ListNotesCommand.java | 2 +- .../src/org/eclipse/jgit/api/MergeCommand.java | 2 +- .../src/org/eclipse/jgit/api/PushCommand.java | 4 ++-- .../src/org/eclipse/jgit/api/RebaseCommand.java | 6 +++--- .../src/org/eclipse/jgit/api/RemoveNoteCommand.java | 2 +- .../src/org/eclipse/jgit/api/RenameBranchCommand.java | 6 +++--- .../src/org/eclipse/jgit/api/ResetCommand.java | 2 +- .../src/org/eclipse/jgit/api/RevertCommand.java | 2 +- .../src/org/eclipse/jgit/api/ShowNoteCommand.java | 2 +- .../src/org/eclipse/jgit/api/StashCreateCommand.java | 4 ++-- .../src/org/eclipse/jgit/api/StashDropCommand.java | 4 ++-- .../src/org/eclipse/jgit/api/StashListCommand.java | 2 +- .../src/org/eclipse/jgit/api/SubmoduleSyncCommand.java | 2 +- .../src/org/eclipse/jgit/api/TagCommand.java | 2 +- .../jgit/internal/storage/file/FileRepository.java | 2 +- .../src/org/eclipse/jgit/lib/BranchTrackingStatus.java | 4 ++-- .../src/org/eclipse/jgit/lib/Repository.java | 4 ++-- .../src/org/eclipse/jgit/submodule/SubmoduleWalk.java | 4 ++-- .../src/org/eclipse/jgit/transport/Transport.java | 2 +- 35 files changed, 58 insertions(+), 58 deletions(-) diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java index 86b87b407..c282df03b 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java @@ -406,7 +406,7 @@ protected RevCommit commitFile(String filename, String contents, String branch) String originalBranch = repo.getFullBranch(); boolean empty = repo.resolve(Constants.HEAD) == null; if (!empty) { - if (repo.getRef(branch) == null) + if (repo.findRef(branch) == null) git.branchCreate().setName(branch).call(); git.checkout().setName(branch).call(); } diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java index 07df56d3f..25e313cee 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java @@ -501,7 +501,7 @@ public RevCommit update(String ref, CommitBuilder to) throws Exception { */ public CommitBuilder amendRef(String ref) throws Exception { String name = normalizeRef(ref); - Ref r = db.getRef(name); + Ref r = db.exactRef(name); if (r == null) throw new IOException("Not a ref: " + ref); 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); pool.parseHeaders(parent); - Ref headRef = db.getRef(Constants.HEAD); + Ref headRef = db.exactRef(Constants.HEAD); if (headRef == null) throw new IOException("Missing HEAD"); RevCommit head = pool.parseCommit(headRef.getObjectId()); @@ -1025,7 +1025,7 @@ public class CommitBuilder { CommitBuilder(BranchBuilder b) throws Exception { branch = b; - Ref ref = db.getRef(branch.ref); + Ref ref = db.exactRef(branch.ref); if (ref != null && ref.getObjectId() != null) parent(pool.parseCommit(ref.getObjectId())); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java index bf6ee3a94..5f3740cbb 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java @@ -169,7 +169,7 @@ protected void run() throws Exception { if (rename) { String src, dst; if (otherBranch == null) { - final Ref head = db.getRef(Constants.HEAD); + final Ref head = db.exactRef(Constants.HEAD); if (head != null && head.isSymbolic()) { src = head.getLeaf().getName(); } else { @@ -178,7 +178,7 @@ protected void run() throws Exception { dst = branch; } else { src = branch; - final Ref old = db.getRef(src); + final Ref old = db.findRef(src); if (old == null) throw die(MessageFormat.format(CLIText.get().doesNotExist, src)); if (!old.getName().startsWith(Constants.R_HEADS)) @@ -204,7 +204,7 @@ protected void run() throws Exception { } else { startBranch = Constants.HEAD; } - Ref startRef = db.getRef(startBranch); + Ref startRef = db.findRef(startBranch); ObjectId startAt = db.resolve(startBranch + "^0"); //$NON-NLS-1$ if (startRef != null) { startBranch = startRef.getName(); @@ -243,7 +243,7 @@ protected void run() 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 if (head != null) { String current = head.getLeaf().getName(); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java index 38d8d70ce..2cfbd86fa 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java @@ -95,7 +95,7 @@ protected void run() throws NoHeadException, NoMessageException, commitCmd.setOnly(p); commitCmd.setAmend(amend); commitCmd.setAll(all); - Ref head = db.getRef(Constants.HEAD); + Ref head = db.exactRef(Constants.HEAD); if (head == null) { throw die(CLIText.get().onBranchToBeBorn); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index 6947cdd10..62e77285b 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -228,7 +228,7 @@ protected void run() throws Exception { } private void addNoteMap(String notesRef) throws IOException { - Ref notes = db.getRef(notesRef); + Ref notes = db.exactRef(notesRef); if (notes == null) return; RevCommit notesCommit = argWalk.parseCommit(notes.getObjectId()); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java index e739b58ae..485efc542 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java @@ -114,7 +114,7 @@ protected void run() throws Exception { } // 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$ if (src == null) throw die(MessageFormat.format( @@ -209,7 +209,7 @@ protected void run() throws Exception { } private Ref getOldHead() throws IOException { - Ref oldHead = db.getRef(Constants.HEAD); + Ref oldHead = db.exactRef(Constants.HEAD); if (oldHead == null) { throw die(CLIText.get().onBranchToBeBorn); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java index 6a6322131..de3df806d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java @@ -204,7 +204,7 @@ private void printPorcelainLine(char x, char y, String path) private void printLongStatus(org.eclipse.jgit.api.Status status) throws IOException { // Print current branch name - final Ref head = db.getRef(Constants.HEAD); + final Ref head = db.exactRef(Constants.HEAD); if (head != null && head.isSymbolic()) { String branch = Repository.shortenRefName(head.getLeaf().getName()); outw.println(CLIText.formatLine(MessageFormat.format( diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java index 725ebc0d2..a4a699ef2 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java @@ -596,7 +596,7 @@ private boolean inIndex(String path) throws IOException { * @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.getObjectId(), ref.getObjectId()); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java index 9cf888195..4235e3786 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java @@ -87,7 +87,7 @@ public Note call() throws GitAPIException { RevCommit notesCommit = null; try (RevWalk walk = new RevWalk(repo); ObjectInserter inserter = repo.newObjectInserter()) { - Ref ref = repo.getRef(notesRef); + Ref ref = repo.findRef(notesRef); // if we have a notes ref, use it if (ref != null) { notesCommit = walk.parseCommit(ref.getObjectId()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java index 6c8028945..65508eff4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java @@ -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) { // TODO Git CLI supports checkout from unborn branch, we should // also allow this @@ -242,7 +242,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException, JGitText.get().checkoutUnexpectedResult, r.name())); this.status = CheckoutResult.NOT_TRIED_RESULT; - return repo.getRef(Constants.HEAD); + return repo.exactRef(Constants.HEAD); } branch = getStartPointObjectId(); } else { @@ -277,7 +277,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException, } finally { dc.unlock(); } - Ref ref = repo.getRef(name); + Ref ref = repo.findRef(name); if (ref != null && !ref.getName().startsWith(Constants.R_HEADS)) ref = null; String toName = Repository.shortenRefName(name); @@ -289,7 +289,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException, updateResult = refUpdate.link(ref.getName()); else if (orphan) { updateResult = refUpdate.link(getBranchName()); - ref = repo.getRef(Constants.HEAD); + ref = repo.exactRef(Constants.HEAD); } else { refUpdate.setNewObjectId(newCommit); updateResult = refUpdate.forceUpdate(); @@ -519,7 +519,7 @@ private void processOptions() throws InvalidRefNameException, .get().branchNameInvalid, name == null ? "" : name)); //$NON-NLS-1$ if (orphan) { - Ref refToCheck = repo.getRef(getBranchName()); + Ref refToCheck = repo.exactRef(getBranchName()); if (refToCheck != null) throw new RefAlreadyExistsException(MessageFormat.format( JGitText.get().refAlreadyExists, name)); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java index d6e930ada..e82a69798 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java @@ -126,7 +126,7 @@ public CherryPickResult call() throws GitAPIException, NoMessageException, try (RevWalk revWalk = new RevWalk(repo)) { // get the head commit - Ref headRef = repo.getRef(Constants.HEAD); + Ref headRef = repo.exactRef(Constants.HEAD); if (headRef == null) throw new NoHeadException( JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java index e54169ade..561319c44 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java @@ -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) throw new NoHeadException( JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java index a6646602e..69d82bcc6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java @@ -125,7 +125,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException, checkCallable(); processOptions(); try (RevWalk revWalk = new RevWalk(repo)) { - Ref refToCheck = repo.getRef(name); + Ref refToCheck = repo.findRef(name); boolean exists = refToCheck != null && refToCheck.getName().startsWith(Constants.R_HEADS); if (!force && exists) @@ -135,7 +135,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException, ObjectId startAt = getStartPointObjectId(); String startPointFullName = null; if (startPoint != null) { - Ref baseRef = repo.getRef(startPoint); + Ref baseRef = repo.findRef(startPoint); if (baseRef != null) startPointFullName = baseRef.getName(); } @@ -207,7 +207,7 @@ public Ref call() throws GitAPIException, RefAlreadyExistsException, .get().createBranchUnexpectedResult, updateResult .name())); - Ref result = repo.getRef(name); + Ref result = repo.findRef(name); if (result == null) throw new JGitInternalException( JGitText.get().createBranchFailedUnknownReason); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteBranchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteBranchCommand.java index 61beb2f0d..ecc1ce5a7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteBranchCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteBranchCommand.java @@ -114,7 +114,7 @@ public List call() throws GitAPIException, for (String branchName : branchNames) { if (branchName == null) continue; - Ref currentRef = repo.getRef(branchName); + Ref currentRef = repo.findRef(branchName); if (currentRef == null) continue; @@ -130,7 +130,7 @@ public List call() throws GitAPIException, for (String branchName : branchNames) { if (branchName == null) continue; - Ref currentRef = repo.getRef(branchName); + Ref currentRef = repo.findRef(branchName); if (currentRef == null) continue; String fullName = currentRef.getName(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteTagCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteTagCommand.java index ae511c6df..3aeec48d9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteTagCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteTagCommand.java @@ -90,7 +90,7 @@ public List call() throws GitAPIException { for (String tagName : tags) { if (tagName == null) continue; - Ref currentRef = repo.getRef(tagName); + Ref currentRef = repo.findRef(tagName); if (currentRef == null) continue; String fullName = currentRef.getName(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java index 904c74f6d..efcfd1682 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java @@ -108,7 +108,7 @@ public List call() throws GitAPIException { Collection refs = new ArrayList(); // 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)) refs.add(head); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListNotesCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListNotesCommand.java index 796ac798f..ff963ede8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListNotesCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListNotesCommand.java @@ -82,7 +82,7 @@ public List call() throws GitAPIException { List notes = new ArrayList(); NoteMap map = NoteMap.newEmptyMap(); 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 (ref != null) { RevCommit notesCommit = walk.parseCommit(ref.getObjectId()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java index bfe90a3a4..38b10971f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java @@ -231,7 +231,7 @@ public MergeResult call() throws GitAPIException, NoHeadException, RevWalk revWalk = null; DirCacheCheckout dco = null; try { - Ref head = repo.getRef(Constants.HEAD); + Ref head = repo.exactRef(Constants.HEAD); if (head == null) throw new NoHeadException( JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java index 367b50931..0a49f7806 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java @@ -131,7 +131,7 @@ public Iterable call() throws GitAPIException, refSpecs.addAll(config.getPushRefSpecs()); } if (refSpecs.isEmpty()) { - Ref head = repo.getRef(Constants.HEAD); + Ref head = repo.exactRef(Constants.HEAD); if (head != null && head.isSymbolic()) refSpecs.add(new RefSpec(head.getLeaf().getName())); } @@ -348,7 +348,7 @@ public PushCommand add(String nameOrSpec) { } else { Ref src; try { - src = repo.getRef(nameOrSpec); + src = repo.findRef(nameOrSpec); } catch (IOException e) { throw new JGitInternalException( JGitText.get().exceptionCaughtDuringExecutionOfPushCommand, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java index 643ec7a51..2d6a76b39 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -419,7 +419,7 @@ private boolean autoStashApply() throws IOException, GitAPIException { private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent, 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.setNewObjectId(commitId); refUpdate.setRefLogIdent(refLogIdent); @@ -750,7 +750,7 @@ private RevCommit doSquashFixup(boolean isSquash, RevCommit commitToPick, private void resetSoftToParent() throws IOException, GitAPIException, CheckoutConflictException { - Ref ref = repo.getRef(Constants.ORIG_HEAD); + Ref ref = repo.exactRef(Constants.ORIG_HEAD); ObjectId orig_head = ref == null ? null : ref.getObjectId(); try { // we have already commited the cherry-picked commit. @@ -1207,7 +1207,7 @@ private static String getHeadName(Ref head) { } private Ref getHead() throws IOException, RefNotFoundException { - Ref head = repo.getRef(Constants.HEAD); + Ref head = repo.exactRef(Constants.HEAD); if (head == null || head.getObjectId() == null) throw new RefNotFoundException(MessageFormat.format( JGitText.get().refNotResolved, Constants.HEAD)); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RemoveNoteCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RemoveNoteCommand.java index a526c2753..1c4880c1e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RemoveNoteCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RemoveNoteCommand.java @@ -85,7 +85,7 @@ public Note call() throws GitAPIException { ObjectInserter inserter = repo.newObjectInserter()) { NoteMap map = NoteMap.newEmptyMap(); RevCommit notesCommit = null; - Ref ref = repo.getRef(notesRef); + Ref ref = repo.exactRef(notesRef); // if we have a notes ref, use it if (ref != null) { notesCommit = walk.parseCommit(ref.getObjectId()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java index 0731dd45e..044a48611 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java @@ -107,11 +107,11 @@ public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameEx try { String fullOldName; String fullNewName; - if (repo.getRef(newName) != null) + if (repo.findRef(newName) != null) throw new RefAlreadyExistsException(MessageFormat.format( JGitText.get().refAlreadyExists1, newName)); if (oldName != null) { - Ref ref = repo.getRef(oldName); + Ref ref = repo.findRef(oldName); if (ref == null) throw new RefNotFoundException(MessageFormat.format( JGitText.get().refNotResolved, oldName)); @@ -186,7 +186,7 @@ public Ref call() throws GitAPIException, RefNotFoundException, InvalidRefNameEx repoConfig.save(); } - Ref resultRef = repo.getRef(newName); + Ref resultRef = repo.findRef(newName); if (resultRef == null) throw new JGitInternalException( JGitText.get().renameBranchFailedUnknownReason); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java index 4c91e6c17..e385a5d17 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java @@ -171,7 +171,7 @@ public Ref call() throws GitAPIException, CheckoutConflictException { // reset [commit] -- paths resetIndexForPaths(commitTree); setCallable(false); - return repo.getRef(Constants.HEAD); + return repo.exactRef(Constants.HEAD); } final Ref result; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java index 801577362..9d79ed029 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java @@ -129,7 +129,7 @@ public RevCommit call() throws NoMessageException, UnmergedPathsException, try (RevWalk revWalk = new RevWalk(repo)) { // get the head commit - Ref headRef = repo.getRef(Constants.HEAD); + Ref headRef = repo.exactRef(Constants.HEAD); if (headRef == null) throw new NoHeadException( JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ShowNoteCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ShowNoteCommand.java index 82db88190..168ea51e7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ShowNoteCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ShowNoteCommand.java @@ -79,7 +79,7 @@ public Note call() throws GitAPIException { NoteMap map = NoteMap.newEmptyMap(); RevCommit notesCommit = null; 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 (ref != null) { notesCommit = walk.parseCommit(ref.getObjectId()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashCreateCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashCreateCommand.java index ef32ac929..ee9b7fcf7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashCreateCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashCreateCommand.java @@ -206,7 +206,7 @@ private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent, String refLogMessage) throws IOException { if (ref == null) return; - Ref currentRef = repo.getRef(ref); + Ref currentRef = repo.findRef(ref); RefUpdate refUpdate = repo.updateRef(ref); refUpdate.setNewObjectId(commitId); refUpdate.setRefLogIdent(refLogIdent); @@ -220,7 +220,7 @@ private void updateStashRef(ObjectId commitId, PersonIdent refLogIdent, private Ref getHead() throws GitAPIException { try { - Ref head = repo.getRef(Constants.HEAD); + Ref head = repo.exactRef(Constants.HEAD); if (head == null || head.getObjectId() == null) throw new NoHeadException(JGitText.get().headRequiredToStash); return head; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java index f6903be05..6e1d0f270 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java @@ -118,7 +118,7 @@ public StashDropCommand setAll(final boolean all) { private Ref getRef() throws GitAPIException { try { - return repo.getRef(R_STASH); + return repo.exactRef(R_STASH); } catch (IOException e) { throw new InvalidRefNameException(MessageFormat.format( JGitText.get().cannotRead, R_STASH), e); @@ -236,7 +236,7 @@ public ObjectId call() throws GitAPIException { updateRef(stashRef, entryId); try { - Ref newStashRef = repo.getRef(R_STASH); + Ref newStashRef = repo.exactRef(R_STASH); return newStashRef != null ? newStashRef.getObjectId() : null; } catch (IOException e) { throw new InvalidRefNameException(MessageFormat.format( diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashListCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashListCommand.java index 59a83aae3..aedc9a6e1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/StashListCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/StashListCommand.java @@ -81,7 +81,7 @@ public Collection call() throws GitAPIException, checkCallable(); try { - if (repo.getRef(Constants.R_STASH) == null) + if (repo.exactRef(Constants.R_STASH) == null) return Collections.emptyList(); } catch (IOException e) { throw new InvalidRefNameException(MessageFormat.format( diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java index e7fe71a89..024f0bebd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java @@ -101,7 +101,7 @@ public SubmoduleSyncCommand addPath(final String path) { * @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()) return Repository.shortenRefName(head.getLeaf().getName()); else diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java index ca98cedfd..39dd42cc5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java @@ -184,7 +184,7 @@ private Ref updateTagRef(ObjectId tagId, RevWalk revWalk, switch (updateResult) { case NEW: case FORCED: - return repo.getRef(refName); + return repo.exactRef(refName); case LOCK_FAILURE: throw new ConcurrentRefUpdateException( JGitText.get().couldNotLockHEAD, tagRef.getRef(), diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java index b02efedea..53fd37e53 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java @@ -491,7 +491,7 @@ public void notifyIndexChanged() { * @throws IOException the ref could not be accessed. */ public ReflogReader getReflogReader(String refName) throws IOException { - Ref ref = getRef(refName); + Ref ref = findRef(refName); if (ref != null) return new ReflogReaderImpl(this, ref.getName()); return null; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java index 1525e5b18..d4fccf907 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java @@ -79,11 +79,11 @@ public static BranchTrackingStatus of(Repository repository, String branchName) if (trackingBranch == null) return null; - Ref tracking = repository.getRef(trackingBranch); + Ref tracking = repository.exactRef(trackingBranch); if (tracking == null) return null; - Ref local = repository.getRef(fullBranchName); + Ref local = repository.exactRef(fullBranchName); if (local == null) return null; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index ba0dea39f..5703dddf1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -898,7 +898,7 @@ public String toString() { * This is essentially the same as doing: * *
-	 * return getRef(Constants.HEAD).getTarget().getName()
+	 * return exactRef(Constants.HEAD).getTarget().getName()
 	 * 
* * Except when HEAD is detached, in which case this method returns the @@ -912,7 +912,7 @@ public String toString() { */ @Nullable public String getFullBranch() throws IOException { - Ref head = getRef(Constants.HEAD); + Ref head = exactRef(Constants.HEAD); if (head == null) { return null; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java index 6263d4b74..5b9e8d902 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java @@ -264,7 +264,7 @@ public static String getSubmoduleRemoteUrl(final Repository parent, String remoteName = null; // 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.isSymbolic()) ref = ref.getLeaf(); @@ -704,7 +704,7 @@ public String getHeadRef() throws IOException { if (subRepo == null) return null; try { - Ref head = subRepo.getRef(Constants.HEAD); + Ref head = subRepo.exactRef(Constants.HEAD); return head != null ? head.getLeaf().getName() : null; } finally { subRepo.close(); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java index 9e6d1f68f..862b3bdeb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java @@ -629,7 +629,7 @@ public static Collection findRemoteRefUpdatesFor( for (final RefSpec spec : procRefs) { String srcSpec = spec.getSource(); - final Ref srcRef = db.getRef(srcSpec); + final Ref srcRef = db.findRef(srcSpec); if (srcRef != null) srcSpec = srcRef.getName();