diff options
author | Jonathan Nieder <jrn@google.com> | 2015-11-19 12:47:18 -0800 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2015-11-25 14:05:24 -0800 |
commit | fe98218e0df85012cb9b901c71c44f232f65cb3a (patch) | |
tree | fdf39c7e0080062487f508f5ea7ec3258faf1fb1 /org.eclipse.jgit | |
parent | 5be4814e38f2c3983dc27ac6d74f95f2d73ed400 (diff) | |
download | jgit-fe98218e0df85012cb9b901c71c44f232f65cb3a.tar.gz jgit-fe98218e0df85012cb9b901c71c44f232f65cb3a.zip |
repo: Do not use search path to find refs/remotes/origin/<branch>
When running from a non-bare repository, "jgit repo" checks whether
the rev passed in is a sha1 or branch name and in the latter case will
check out origin/<branch>.
We are expecting refs/remotes/origin/<branch>, but as a side effect of
using getRef we also end up looking for refs/origin/<branch>,
refs/heads/origin/<branch>, and so on. Avoid that by using exactRef
instead.
Signed-off-by: Jonathan Nieder <jrn@google.com>
Change-Id: I670b2e48a88138a1f2104ea201baa958e9edbddb
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java index 1d2d3bfaaf..ff9f233aa5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/RepoCommand.java @@ -42,6 +42,9 @@ */ package org.eclipse.jgit.gitrepo; +import static org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME; +import static org.eclipse.jgit.lib.Constants.R_REMOTES; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -574,7 +577,7 @@ public class RepoCommand extends GitCommand<RevCommit> { private static String findRef(String ref, Repository repo) throws IOException { if (!ObjectId.isId(ref)) { - Ref r = repo.getRef(Constants.DEFAULT_REMOTE_NAME + "/" + ref); //$NON-NLS-1$ + Ref r = repo.exactRef(R_REMOTES + DEFAULT_REMOTE_NAME + "/" + ref); //$NON-NLS-1$ if (r != null) return r.getName(); } |