diff options
author | Jonathan Nieder <jrn@google.com> | 2015-06-05 15:20:24 -0700 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2015-11-25 14:05:20 -0800 |
commit | 5be4814e38f2c3983dc27ac6d74f95f2d73ed400 (patch) | |
tree | 33847b9f7f772f397a7855000c972db652c9c699 /org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java | |
parent | 830117e761bddc182e4dc57150ca661976868203 (diff) | |
download | jgit-5be4814e38f2c3983dc27ac6d74f95f2d73ed400.tar.gz jgit-5be4814e38f2c3983dc27ac6d74f95f2d73ed400.zip |
Repository: Introduce exactRef and findRef, deprecate getRef
The Repository class provides only one method to look up a ref by
name, getRef. If I request refs/heads/master and that ref does not
exist, getRef will look further in the search path:
ref/refs/heads/master
refs/heads/refs/heads/master
refs/remotes/refs/heads/master
This behavior is counterintuitive, needlessly inexpensive, and usually
not what the caller expects.
Allow callers to specify whether to use the search path by providing
two separate methods:
- exactRef, which looks up a ref when its exact name is known
- findRef, which looks for a ref along the search path
For backward compatibility, keep getRef as a deprecated synonym for
findRef.
This change introduces findRef and exactRef but does not update
callers outside tests to use them yet.
Change-Id: I35375d942baeb3ded15520388f8ebb9c0cc86f8c
Signed-off-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java')
-rw-r--r-- | org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java index 7bf4c26c38..939a9f6fdd 100644 --- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java +++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java @@ -198,7 +198,8 @@ public class CheckoutTest extends CLIRepositoryTestCase { assertStringArrayEquals("Switched to a new branch 'new_branch'", execute("git checkout --orphan new_branch")); - assertEquals("refs/heads/new_branch", db.getRef("HEAD").getTarget().getName()); + assertEquals("refs/heads/new_branch", + db.exactRef("HEAD").getTarget().getName()); RevCommit commit = git.commit().setMessage("orphan commit").call(); assertEquals(0, commit.getParentCount()); } |