]> source.dussan.org Git - jgit.git/commitdiff
Replace use of deprecated method Repository.getRef() 53/73253/2
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 20 May 2016 09:28:21 +0000 (11:28 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 30 May 2016 22:11:11 +0000 (00:11 +0200)
Change-Id: Iecf2b8deafc4991cc3333702fb9fa0638be7b914
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
35 files changed:
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/ResetCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/AddNoteCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/CreateBranchCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteBranchCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/DeleteTagCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/ListBranchCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/ListNotesCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RemoveNoteCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RenameBranchCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/ResetCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/ShowNoteCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/StashCreateCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/StashDropCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/StashListCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleSyncCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/BranchTrackingStatus.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
org.eclipse.jgit/src/org/eclipse/jgit/submodule/SubmoduleWalk.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java

index 86b87b40755acfc1ca1e9fea35725e22ceef37ab..c282df03bd205bcb78301941638bc9320b8b026f 100644 (file)
@@ -406,7 +406,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
                        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();
                        }
index 07df56d3f1e12f9d94791d425cbf6d4529ddcf9a..25e313cee6695d6de09992b4d1c2ba62b4272131 100644 (file)
@@ -501,7 +501,7 @@ public class TestRepository<R extends Repository> {
         */
        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 class TestRepository<R extends Repository> {
                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 TestRepository<R extends Repository> {
                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()));
                }
index bf6ee3a9453c4b84e965f2cb487bf374cd9e181f..5f3740cbba948345c4ac811b50f8c131b332c6a0 100644 (file)
@@ -169,7 +169,7 @@ class Branch extends TextBuiltin {
                        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 @@ class Branch extends TextBuiltin {
                                        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 @@ class Branch extends TextBuiltin {
                                } 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 @@ class Branch extends TextBuiltin {
        }
 
        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();
index 38d8d70cefbbdc76439be89cc64fcf79107ccb9f..2cfbd86fa3f50e7152696119be9c96eb1e04b4f1 100644 (file)
@@ -95,7 +95,7 @@ class Commit extends TextBuiltin {
                                        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);
                        }
index 6947cdd100fbfe37a11a7a161c6374509eb67db6..62e77285b946cdcec535b3d78dffea2beda7478c 100644 (file)
@@ -228,7 +228,7 @@ class Log extends RevWalkTextBuiltin {
        }
 
        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());
index e739b58ae7c4e48b51baa11b85923a80906c6fc3..485efc5428242f94ad264f7dca23755f85c61844 100644 (file)
@@ -114,7 +114,7 @@ class Merge extends TextBuiltin {
                }
 
                // 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 @@ class Merge extends TextBuiltin {
        }
 
        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);
                }
index 6a6322131ad6194c68e6b3bf28f5b36e03f17e07..de3df806d899ba8222a4e6f118b3ae0ffeffbc92 100644 (file)
@@ -204,7 +204,7 @@ class Status extends TextBuiltin {
        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(
index 725ebc0d236726f707fe22c47379d08b532b7f77..a4a699ef2261ea577abdd29d9d9463a6089ef6a7 100644 (file)
@@ -596,7 +596,7 @@ public class ResetCommandTest extends RepositoryTestCase {
         * @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());
        }
index 9cf888195e7fca540462fa6457bd427b0e04390f..4235e3786cb7cc7d8e6e63f60d4fe7557c3c4321 100644 (file)
@@ -87,7 +87,7 @@ public class AddNoteCommand extends GitCommand<Note> {
                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());
index 6c80289452fbd748f4d40731d70e122b82fe7ca1..65508eff4054aced91a2f94ea9d37b37181fadf1 100644 (file)
@@ -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) {
                                // TODO Git CLI supports checkout from unborn branch, we should
                                // also allow this
@@ -242,7 +242,7 @@ public class CheckoutCommand extends GitCommand<Ref> {
                                                                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 class CheckoutCommand extends GitCommand<Ref> {
                        } 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 class CheckoutCommand extends GitCommand<Ref> {
                                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 @@ public class CheckoutCommand extends GitCommand<Ref> {
                                        .get().branchNameInvalid, name == null ? "<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));
index d6e930adac0a40c9586a525f4aaa2b6c9c4d6207..e82a69798f85bc315384e0d4f7d1db0f25487a77 100644 (file)
@@ -126,7 +126,7 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
                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);
index e54169adec1c7c097995c606d999d335e4f80134..561319c44a8fbbed3c56e4ac5c0acddb19354bef 100644 (file)
@@ -195,7 +195,7 @@ public class CommitCommand extends GitCommand<RevCommit> {
                                }
                        }
 
-                       Ref head = repo.getRef(Constants.HEAD);
+                       Ref head = repo.exactRef(Constants.HEAD);
                        if (head == null)
                                throw new NoHeadException(
                                                JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
index a6646602e9ff4aee340e3f5c8aa0abc4d7a78447..69d82bcc67d2f6c5ba24bb7c29bb6a054b67887e 100644 (file)
@@ -125,7 +125,7 @@ public class CreateBranchCommand extends GitCommand<Ref> {
                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 class CreateBranchCommand extends GitCommand<Ref> {
                        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 class CreateBranchCommand extends GitCommand<Ref> {
                                                .get().createBranchUnexpectedResult, updateResult
                                                .name()));
 
-                       Ref result = repo.getRef(name);
+                       Ref result = repo.findRef(name);
                        if (result == null)
                                throw new JGitInternalException(
                                                JGitText.get().createBranchFailedUnknownReason);
index 61beb2f0d07fe2677b24b675dc2144c6a4c80349..ecc1ce5a7030d542dddeb7089ad3ba154447fa29 100644 (file)
@@ -114,7 +114,7 @@ public class DeleteBranchCommand extends GitCommand<List<String>> {
                                        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 class DeleteBranchCommand extends GitCommand<List<String>> {
                        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();
index ae511c6df0e130d8c7f82da8c9fbb217e6a22d89..3aeec48d9de7d5a2f6295faac33d1435dc3e463c 100644 (file)
@@ -90,7 +90,7 @@ public class DeleteTagCommand extends GitCommand<List<String>> {
                        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();
index 904c74f6ded625231c75b269029dba333713251f..efcfd16823c1b1ad7d48b909350c09a8b8c8ddec 100644 (file)
@@ -108,7 +108,7 @@ public class ListBranchCommand extends GitCommand<List<Ref>> {
                        Collection<Ref> refs = new ArrayList<Ref>();
 
                        // 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);
 
index 796ac798f0b849fbde7b46fd246f3a3288c1b849..ff963ede891a6159182fec2b60ea657e5dab42ab 100644 (file)
@@ -82,7 +82,7 @@ public class ListNotesCommand extends GitCommand<List<Note>> {
                List<Note> notes = new ArrayList<Note>();
                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());
index bfe90a3a4f9f25e5d5949d79bcaf4e6921db82c8..38b10971f46da82698c22e4537809d75c53cb5b7 100644 (file)
@@ -231,7 +231,7 @@ public class MergeCommand extends GitCommand<MergeResult> {
                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);
index 367b509317c5da5964c2d2bf409994b33cb53c39..0a49f78069a63b70a55cbb94c2c5a161ffddf92a 100644 (file)
@@ -131,7 +131,7 @@ public class PushCommand extends
                                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 class PushCommand extends
                } else {
                        Ref src;
                        try {
-                               src = repo.getRef(nameOrSpec);
+                               src = repo.findRef(nameOrSpec);
                        } catch (IOException e) {
                                throw new JGitInternalException(
                                                JGitText.get().exceptionCaughtDuringExecutionOfPushCommand,
index 643ec7a51fa6eab554dbbe444a14d8b95e718b98..2d6a76b3905a89b80ceee5321f5525ad8490073e 100644 (file)
@@ -419,7 +419,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
 
        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 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
 
        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 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
        }
 
        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));
index a526c275310d3ec6c7f8576f787930c4934150e2..1c4880c1e14d00961f93555b6f77f7bd59ac1201 100644 (file)
@@ -85,7 +85,7 @@ public class RemoveNoteCommand extends GitCommand<Note> {
                                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());
index 0731dd45ec75179d51eee5b47fac295f4e0e5acb..044a48611b5a9534ffc48cea4c45a1e7f1a94a41 100644 (file)
@@ -107,11 +107,11 @@ public class RenameBranchCommand extends GitCommand<Ref> {
                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 class RenameBranchCommand extends GitCommand<Ref> {
                                repoConfig.save();
                        }
 
-                       Ref resultRef = repo.getRef(newName);
+                       Ref resultRef = repo.findRef(newName);
                        if (resultRef == null)
                                throw new JGitInternalException(
                                                JGitText.get().renameBranchFailedUnknownReason);
index 4c91e6c17fa51b0883cb1212d4ef1131e590c294..e385a5d174f861c7f3cf8a077204ab2a75b47745 100644 (file)
@@ -171,7 +171,7 @@ public class ResetCommand extends GitCommand<Ref> {
                                // reset [commit] -- paths
                                resetIndexForPaths(commitTree);
                                setCallable(false);
-                               return repo.getRef(Constants.HEAD);
+                               return repo.exactRef(Constants.HEAD);
                        }
 
                        final Ref result;
index 8015773624184f79d4abc5b4c2696d5b40504ba3..9d79ed02995b6f43acd7a74e44779b42d334fc27 100644 (file)
@@ -129,7 +129,7 @@ public class RevertCommand extends GitCommand<RevCommit> {
                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);
index 82db88190f158f60ed1c4fd4035d0519c98d904d..168ea51e77763f65137574712078eb18abf2a5b8 100644 (file)
@@ -79,7 +79,7 @@ public class ShowNoteCommand extends GitCommand<Note> {
                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());
index ef32ac929ac67cb8b3db416abbd2f57121a01c5b..ee9b7fcf7266259f5c35334151a3c9e001662ab8 100644 (file)
@@ -206,7 +206,7 @@ public class StashCreateCommand extends GitCommand<RevCommit> {
                        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 @@ public class StashCreateCommand extends GitCommand<RevCommit> {
 
        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;
index f6903be05c67c6f9675fff844b6bad5718547847..6e1d0f270363dcce9ee1f3556adf5f3b19135a50 100644 (file)
@@ -118,7 +118,7 @@ public class StashDropCommand extends GitCommand<ObjectId> {
 
        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 class StashDropCommand extends GitCommand<ObjectId> {
                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(
index 59a83aae3f9cf4f8b2e0a323be3bdd31436a776b..aedc9a6e12b68eb542f0b62500e7371bc62f1a0f 100644 (file)
@@ -81,7 +81,7 @@ public class StashListCommand extends GitCommand<Collection<RevCommit>> {
                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(
index e7fe71a8907430a59ae8740aeb4af46eb47f2359..024f0bebdef522c81987dbdab7a1ec5edfd75697 100644 (file)
@@ -101,7 +101,7 @@ public class SubmoduleSyncCommand extends GitCommand<Map<String, String>> {
         * @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
index ca98cedfd84f151ae3ac5465ca62d0e811bcfa29..39dd42cc5197ea8ac3a7c19287dc921e73587fdd 100644 (file)
@@ -184,7 +184,7 @@ public class TagCommand extends GitCommand<Ref> {
                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(),
index b02efedea35052486e18f7057bc0426bc6d4fef0..53fd37e534e7ef3bec186cf554df819bbecda301 100644 (file)
@@ -491,7 +491,7 @@ public class FileRepository extends Repository {
         * @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;
index 1525e5b187dc2bc262d4e66d01d40a4721206dfc..d4fccf9070c8778a8d0a491efa84a311a2a0c065 100644 (file)
@@ -79,11 +79,11 @@ public class BranchTrackingStatus {
                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;
 
index ba0dea39f504e637d237d9cd2683e07f80646da9..5703dddf1d914613ae796e6864033fee969522b5 100644 (file)
@@ -898,7 +898,7 @@ public abstract class Repository implements AutoCloseable {
         * This is essentially the same as doing:
         *
         * <pre>
-        * return getRef(Constants.HEAD).getTarget().getName()
+        * return exactRef(Constants.HEAD).getTarget().getName()
         * </pre>
         *
         * Except when HEAD is detached, in which case this method returns the
@@ -912,7 +912,7 @@ public abstract class Repository implements AutoCloseable {
         */
        @Nullable
        public String getFullBranch() throws IOException {
-               Ref head = getRef(Constants.HEAD);
+               Ref head = exactRef(Constants.HEAD);
                if (head == null) {
                        return null;
                }
index 6263d4b74d1e192c5c185ab66e286ad2bfcd06a3..5b9e8d9029896db93ec5da6d19536ef84685c374 100644 (file)
@@ -264,7 +264,7 @@ public class SubmoduleWalk implements AutoCloseable {
 
                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 class SubmoduleWalk implements AutoCloseable {
                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();
index 9e6d1f68f5e5fbc808a654a94c9492e1e52f7033..862b3bdeb0d79c78751f062ae7505b79b28f773f 100644 (file)
@@ -629,7 +629,7 @@ public abstract class Transport implements AutoCloseable {
 
                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();