Example usage for org.eclipse.jgit.lib Constants DEFAULT_REMOTE_NAME

List of usage examples for org.eclipse.jgit.lib Constants DEFAULT_REMOTE_NAME

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants DEFAULT_REMOTE_NAME.

Prototype

String DEFAULT_REMOTE_NAME

To view the source code for org.eclipse.jgit.lib Constants DEFAULT_REMOTE_NAME.

Click Source Link

Document

Default remote name used by clone, push and fetch operations

Usage

From source file:org.eclipse.mylyn.internal.github.ui.gist.CloneGistHandler.java

License:Open Source License

private CloneOperation createCloneOperation(TaskData data, String name) throws IOException, URISyntaxException {
    String pullUrl = data.getRoot().getAttribute(GistAttribute.CLONE_URL.getMetadata().getId()).getValue();
    URIish uri = new URIish(pullUrl);
    int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
    final File workDir = new File(getParentDirectory(), name);

    if (getRepoUtil().getConfiguredRepositories()
            .contains(new File(workDir, Constants.DOT_GIT).getAbsolutePath()))
        throw new IOException(MessageFormat.format(Messages.CloneGistHandler_ErrorRepoExists, name));

    return new CloneOperation(uri, true, null, workDir, Constants.R_HEADS + Constants.MASTER,
            Constants.DEFAULT_REMOTE_NAME, timeout);
}

From source file:org.eclipse.mylyn.internal.github.ui.pr.CheckoutPullRequestHandler.java

License:Open Source License

public Object execute(final ExecutionEvent event) throws ExecutionException {
    final TaskData data = getTaskData(event);
    if (data == null)
        return null;

    Job job = new Job(MessageFormat.format(Messages.CheckoutPullRequestHandler_JobName, data.getTaskId())) {

        protected IStatus run(IProgressMonitor monitor) {
            SubProgressMonitor sub;/*from   w  w w.  j  a  v a2 s  .  com*/
            try {
                PullRequestComposite prComp = PullRequestConnector.getPullRequest(data);
                if (prComp == null)
                    return Status.CANCEL_STATUS;
                PullRequest request = prComp.getRequest();
                Repository repo = PullRequestUtils.getRepository(request);
                if (repo == null)
                    return Status.CANCEL_STATUS;

                String branchName = PullRequestUtils.getBranchName(request);
                Ref branchRef = repo.getRef(branchName);
                RemoteConfig remote = null;
                String headBranch = null;

                monitor.beginTask("", 5); //$NON-NLS-1$

                // Add remote
                if (!PullRequestUtils.isFromSameRepository(request)) {
                    monitor.subTask(MessageFormat.format(Messages.CheckoutPullRequestHandler_TaskAddRemote,
                            request.getHead().getRepo().getOwner().getLogin()));
                    remote = PullRequestUtils.addRemote(repo, request);
                    headBranch = PullRequestUtils.getHeadBranch(request);
                } else {
                    remote = PullRequestUtils.getRemoteConfig(repo, Constants.DEFAULT_REMOTE_NAME);
                    headBranch = request.getHead().getRef();
                }
                monitor.worked(1);

                // Create topic branch starting at SHA-1 of base
                if (branchRef == null) {
                    sub = new SubProgressMonitor(monitor, 1);
                    sub.subTask(MessageFormat.format(Messages.CheckoutPullRequestHandler_TaskCreateBranch,
                            branchName));
                    PullRequestUtils.configureTopicBranch(repo, request);
                    new CreateLocalBranchOperation(repo, branchName, getBase(repo, request)).execute(sub);
                    sub.done();
                } else
                    monitor.worked(1);

                // Checkout topic branch
                if (!PullRequestUtils.isCurrentBranch(branchName, repo)) {
                    sub = new SubProgressMonitor(monitor, 1);
                    sub.subTask(MessageFormat.format(Messages.CheckoutPullRequestHandler_TaskCheckoutBranch,
                            branchName));
                    BranchOperationUI.checkout(repo, branchName).run(sub);
                    sub.done();
                } else
                    monitor.worked(1);

                // Fetch from remote
                sub = new SubProgressMonitor(monitor, 1);
                sub.subTask(MessageFormat.format(Messages.CheckoutPullRequestHandler_TaskFetching,
                        remote.getName()));
                new FetchOperation(repo, remote, Activator.getDefault().getPreferenceStore()
                        .getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT), false).run(sub);
                sub.done();

                // Merge head onto base
                sub = new SubProgressMonitor(monitor, 1);
                sub.subTask(MessageFormat.format(Messages.CheckoutPullRequestHandler_TaskMerging, headBranch));
                new MergeOperation(repo, headBranch).execute(sub);
                sub.done();

                monitor.done();
                executeCallback(event);
            } catch (IOException e) {
                GitHubUi.logError(e);
            } catch (CoreException e) {
                GitHubUi.logError(e);
            } catch (URISyntaxException e) {
                GitHubUi.logError(e);
            } catch (InvocationTargetException e) {
                GitHubUi.logError(e);
            }
            return Status.OK_STATUS;
        }
    };
    schedule(job, event);
    return null;
}

From source file:org.eclipse.mylyn.internal.github.ui.RepositoryImportWizard.java

License:Open Source License

private CloneOperation createCloneOperation(SearchRepository repo, RepositoryService service)
        throws IOException, URISyntaxException {
    Repository fullRepo = service.getRepository(repo);
    URIish uri = new URIish(fullRepo.getCloneUrl());

    IPreferenceStore store = org.eclipse.egit.ui.Activator.getDefault().getPreferenceStore();

    String defaultRepoDir = store.getString(UIPreferences.DEFAULT_REPO_DIR);
    File directory = new File(new File(defaultRepoDir, repo.getOwner()), repo.getName());

    int timeout = store.getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);

    return new CloneOperation(uri, true, null, directory, Constants.R_HEADS + Constants.MASTER,
            Constants.DEFAULT_REMOTE_NAME, timeout);
}

From source file:org.eclipse.orion.server.git.BaseToRemoteConverter.java

License:Open Source License

public static URI getRemoteBranchLocation(URI base, String branchName, Repository db,
        BaseToRemoteConverter converter) throws IOException, URISyntaxException {
    Config repoConfig = db.getConfig();/*ww w.j  av  a2 s .  co m*/
    String remote = repoConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
            ConfigConstants.CONFIG_KEY_REMOTE);
    if (remote == null)
        // fall back to default remote
        remote = Constants.DEFAULT_REMOTE_NAME;
    String fetch = repoConfig.getString(ConfigConstants.CONFIG_REMOTE_SECTION, remote, "fetch"); //$NON-NLS-1$
    if (fetch != null) {
        // expecting something like: +refs/heads/*:refs/remotes/origin/*
        String[] split = fetch.split(":"); //$NON-NLS-1$
        if (split[0].endsWith("*") /*src*/ && split[1].endsWith("*") /*dst*/) { //$NON-NLS-1$ //$NON-NLS-2$
            return converter.baseToRemoteLocation(base, remote, branchName);
        }
    }
    return null;
}

From source file:org.eclipse.orion.server.git.jobs.CloneJob.java

License:Open Source License

private IStatus doClone() {
    try {/*  ww w  .  jav  a 2 s  .c om*/
        File cloneFolder = new File(clone.getContentLocation().getPath());
        if (!cloneFolder.exists()) {
            cloneFolder.mkdir();
        }
        CloneCommand cc = Git.cloneRepository();
        cc.setBare(false);
        cc.setCredentialsProvider(credentials);
        cc.setDirectory(cloneFolder);
        cc.setRemote(Constants.DEFAULT_REMOTE_NAME);
        cc.setURI(clone.getUrl());
        Git git = cc.call();

        // Configure the clone, see Bug 337820
        GitCloneHandlerV1.doConfigureClone(git, user);
        git.getRepository().close();
    } catch (IOException e) {
        return new Status(IStatus.ERROR, GitActivator.PI_GIT, "Error cloning git repository", e);
    } catch (CoreException e) {
        return e.getStatus();
    } catch (GitAPIException e) {
        return getGitAPIExceptionStatus(e, "Error cloning git repository");
    } catch (JGitInternalException e) {
        return getJGitInternalExceptionStatus(e, "Error cloning git repository");
    } catch (Exception e) {
        return new Status(IStatus.ERROR, GitActivator.PI_GIT, "Error cloning git repository", e);
    }
    JSONObject jsonData = new JSONObject();
    try {
        jsonData.put(ProtocolConstants.KEY_LOCATION, URI.create(this.cloneLocation));
    } catch (JSONException e) {
        // Should not happen
    }
    return new ServerStatus(Status.OK_STATUS, HttpServletResponse.SC_OK, jsonData);
}

From source file:org.eclipse.orion.server.git.objects.Clone.java

License:Open Source License

@PropertyDescription(name = GitConstants.KEY_URL)
private String getCloneUrl() {
    try {//from w  ww  .ja  va 2 s .  c o  m
        FileBasedConfig config = getRepository().getConfig();
        String remoteUri = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION,
                Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL);
        if (remoteUri != null)
            return remoteUri;
    } catch (IOException e) {
        // ignore and skip Git URL
    }
    return null;
}

From source file:org.eclipse.orion.server.git.objects.Remote.java

License:Open Source License

@PropertyDescription(name = ProtocolConstants.KEY_CHILDREN)
private JSONArray getChildren() throws IOException, JSONException, URISyntaxException, CoreException {
    JSONArray children = new JSONArray();
    boolean branchFound = false;
    List<Ref> refs = new ArrayList<Ref>();
    String currentBranch = db.getBranch();
    for (Entry<String, Ref> refEntry : db.getRefDatabase().getRefs(Constants.R_REMOTES + name + "/") //$NON-NLS-1$
            .entrySet()) {//from   w w w .  j a  v  a 2  s.  c o  m
        if (!refEntry.getValue().isSymbolic()) {
            Ref ref = refEntry.getValue();
            String name = ref.getName();
            name = Repository.shortenRefName(name).substring(Constants.DEFAULT_REMOTE_NAME.length() + 1);
            if (currentBranch.equals(name)) {
                refs.add(0, ref);
            } else {
                refs.add(ref);
            }
        }
    }
    for (Ref ref : refs) {
        String remoteBranchName = Repository.shortenRefName(ref.getName());
        remoteBranchName = remoteBranchName.substring((this.name + "/").length()); //$NON-NLS-1$
        RemoteBranch remoteBranch = new RemoteBranch(cloneLocation, db, this, remoteBranchName);
        children.put(remoteBranch.toJSON());
        if (newBranch != null && !newBranch.isEmpty() && remoteBranchName.equals(newBranch)) {
            children = new JSONArray().put(remoteBranch.toJSON());
            branchFound = true;
            break;
        }
    }

    if (!branchFound && newBranch != null && !newBranch.isEmpty()) {
        JSONObject o = new JSONObject();
        // TODO: this should be a RemoteBranch
        String name = Constants.R_REMOTES + getName() + "/" + newBranch; //$NON-NLS-1$
        o.put(ProtocolConstants.KEY_NAME, name.substring(Constants.R_REMOTES.length()));
        o.put(ProtocolConstants.KEY_FULL_NAME, name);
        o.put(ProtocolConstants.KEY_TYPE, RemoteBranch.TYPE);
        o.put(ProtocolConstants.KEY_LOCATION,
                BaseToRemoteConverter.REMOVE_FIRST_2.baseToRemoteLocation(cloneLocation, "", //$NON-NLS-1$
                        /*short name is {remote}/{branch}*/getName() + "/" + GitUtils.encode(newBranch)));
        children.put(o);
    }

    return children;
}

From source file:org.eclipse.orion.server.git.servlets.CloneJob.java

License:Open Source License

private IStatus doClone() {
    try {/*from  w w  w  .  j av  a2s. com*/
        File cloneFolder = new File(clone.getContentLocation().getPath());
        if (!cloneFolder.exists()) {
            cloneFolder.mkdir();
        }
        CloneCommand cc = Git.cloneRepository();
        cc.setBare(false);
        cc.setCredentialsProvider(credentials);
        cc.setDirectory(cloneFolder);
        cc.setRemote(Constants.DEFAULT_REMOTE_NAME);
        cc.setURI(clone.getUrl());
        Git git = cc.call();

        // Configure the clone, see Bug 337820
        task.setMessage(NLS.bind("Configuring {0}...", clone.getUrl()));
        updateTask(task);
        GitCloneHandlerV1.doConfigureClone(git, user);
        git.getRepository().close();
    } catch (IOException e) {
        return new Status(IStatus.ERROR, GitActivator.PI_GIT, "Error cloning git repository", e);
    } catch (CoreException e) {
        return e.getStatus();
    } catch (JGitInternalException e) {
        return getJGitInternalExceptionStatus(e, "An internal git error cloning git repository");
    } catch (Exception e) {
        return new Status(IStatus.ERROR, GitActivator.PI_GIT, "Error cloning git repository", e);
    }
    return Status.OK_STATUS;
}

From source file:org.eclipse.orion.server.git.servlets.GitCloneHandlerV1.java

License:Open Source License

private JSONObject toJSON(Entry<IPath, File> entry, URI baseLocation) throws URISyntaxException {
    IPath k = entry.getKey();//from  w ww.ja  v  a 2 s  .  c o m
    JSONObject result = new JSONObject();
    try {
        result.put(ProtocolConstants.KEY_ID, k);

        result.put(ProtocolConstants.KEY_NAME,
                k.segmentCount() == 1 ? WebProject.fromId(k.segment(0)).getName() : k.lastSegment());

        IPath np = new Path(GitServlet.GIT_URI).append(GitConstants.CLONE_RESOURCE).append("file").append(k); //$NON-NLS-1$
        URI location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(),
                baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment());
        result.put(ProtocolConstants.KEY_LOCATION, location);

        np = new Path("file").append(k).makeAbsolute(); //$NON-NLS-1$
        location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(),
                baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment());
        result.put(ProtocolConstants.KEY_CONTENT_LOCATION, location);

        np = new Path(GitServlet.GIT_URI).append(GitConstants.REMOTE_RESOURCE).append("file").append(k); //$NON-NLS-1$
        location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(),
                baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment());
        result.put(GitConstants.KEY_REMOTE, location);

        np = new Path(GitServlet.GIT_URI).append(GitConstants.CONFIG_RESOURCE)
                .append(GitConstants.CLONE_RESOURCE).append("file").append(k); //$NON-NLS-1$
        location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(),
                baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment());
        result.put(GitConstants.KEY_CONFIG, location);

        np = new Path(GitServlet.GIT_URI).append(GitConstants.COMMIT_RESOURCE).append(Constants.HEAD)
                .append("file").append(k); //$NON-NLS-1$
        location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(),
                baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment());
        result.put(GitConstants.KEY_HEAD, location);

        np = new Path(GitServlet.GIT_URI).append(GitConstants.COMMIT_RESOURCE).append("file").append(k); //$NON-NLS-1$
        location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(),
                baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment());
        result.put(GitConstants.KEY_COMMIT, location);

        np = new Path(GitServlet.GIT_URI).append(GitConstants.BRANCH_RESOURCE).append("file").append(k); //$NON-NLS-1$
        location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(),
                baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment());
        result.put(GitConstants.KEY_BRANCH, location);

        np = new Path(GitServlet.GIT_URI).append(GitConstants.INDEX_RESOURCE).append("file").append(k); //$NON-NLS-1$
        location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(),
                baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment());
        result.put(GitConstants.KEY_INDEX, location);

        np = new Path(GitServlet.GIT_URI).append(GitConstants.STATUS_RESOURCE).append("file").append(k); //$NON-NLS-1$
        location = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(),
                baseLocation.getPort(), np.toString(), baseLocation.getQuery(), baseLocation.getFragment());
        result.put(GitConstants.KEY_STATUS, location);

        try {
            FileBasedConfig config = new FileRepository(entry.getValue()).getConfig();
            String remoteUri = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION,
                    Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL);
            if (remoteUri != null)
                result.put(GitConstants.KEY_URL, remoteUri);
        } catch (IOException e) {
            // ignore and skip Git URL
        }
    } catch (JSONException e) {
        //cannot happen, we know keys and values are valid
    }
    return result;
}

From source file:org.eclipse.orion.server.git.servlets.GitRemoteHandlerV1.java

License:Open Source License

private boolean handleGet(HttpServletRequest request, HttpServletResponse response, String path)
        throws IOException, JSONException, ServletException, URISyntaxException, CoreException {
    Path p = new Path(path);
    // FIXME: what if a remote or branch is named "file"?
    if (p.segment(0).equals("file")) { //$NON-NLS-1$
        // /git/remote/file/{path}
        File gitDir = GitUtils.getGitDir(p);
        Repository db = new FileRepository(gitDir);
        Set<String> configNames = db.getConfig().getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
        JSONObject result = new JSONObject();
        JSONArray children = new JSONArray();
        URI baseLocation = getURI(request);
        for (String configName : configNames) {
            JSONObject o = new JSONObject();
            o.put(ProtocolConstants.KEY_NAME, configName);
            o.put(ProtocolConstants.KEY_TYPE, GitConstants.KEY_REMOTE_NAME);
            o.put(GitConstants.KEY_URL, db.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION,
                    configName, "url" /*RemoteConfig.KEY_URL*/));
            String pushUrl = null;
            if ((pushUrl = db.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION, configName,
                    "pushurl" /*RemoteConfig.KEY_PUSHURL*/)) != null)
                o.put(GitConstants.KEY_PUSH_URL, pushUrl);
            o.put(ProtocolConstants.KEY_LOCATION, BaseToRemoteConverter.REMOVE_FIRST_2
                    .baseToRemoteLocation(baseLocation, configName, "" /* no branch name */)); //$NON-NLS-1$
            children.put(o);/* ww  w . j a  va 2 s.c o m*/
        }
        result.put(ProtocolConstants.KEY_CHILDREN, children);
        OrionServlet.writeJSONResponse(request, response, result);
        return true;
    } else if (p.segment(1).equals("file")) { //$NON-NLS-1$
        // /git/remote/{remote}/file/{path}
        File gitDir = GitUtils.getGitDir(p.removeFirstSegments(1));
        Repository db = new FileRepository(gitDir);
        Set<String> configNames = db.getConfig().getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
        JSONObject result = new JSONObject();
        URI baseLocation = getURI(request);

        for (String configName : configNames) {
            if (configName.equals(p.segment(0))) {
                result.put(ProtocolConstants.KEY_NAME, configName);
                result.put(ProtocolConstants.KEY_TYPE, GitConstants.KEY_REMOTE_NAME);
                result.put(ProtocolConstants.KEY_LOCATION, BaseToRemoteConverter.REMOVE_FIRST_3
                        .baseToRemoteLocation(baseLocation, p.segment(0), "" /* no branch name */)); //$NON-NLS-1$

                JSONArray children = new JSONArray();
                List<Ref> refs = new ArrayList<Ref>();
                for (Entry<String, Ref> refEntry : db.getRefDatabase()
                        .getRefs(Constants.R_REMOTES + p.uptoSegment(1)).entrySet()) {
                    if (!refEntry.getValue().isSymbolic()) {
                        Ref ref = refEntry.getValue();
                        String name = ref.getName();
                        name = Repository.shortenRefName(name)
                                .substring(Constants.DEFAULT_REMOTE_NAME.length() + 1);
                        if (db.getBranch().equals(name)) {
                            refs.add(0, ref);
                        } else {
                            refs.add(ref);
                        }
                    }
                }
                for (Ref ref : refs) {
                    JSONObject o = new JSONObject();
                    String name = ref.getName();
                    o.put(ProtocolConstants.KEY_NAME, name.substring(Constants.R_REMOTES.length()));
                    o.put(ProtocolConstants.KEY_FULL_NAME, name);
                    o.put(ProtocolConstants.KEY_TYPE, GitConstants.REMOTE_TRACKING_BRANCH_TYPE);
                    o.put(ProtocolConstants.KEY_ID, ref.getObjectId().name());
                    // see bug 342602
                    // o.put(GitConstants.KEY_COMMIT, baseToCommitLocation(baseLocation, name));
                    o.put(ProtocolConstants.KEY_LOCATION,
                            BaseToRemoteConverter.REMOVE_FIRST_3.baseToRemoteLocation(baseLocation,
                                    "" /*short name is {remote}/{branch}*/, Repository.shortenRefName(name))); //$NON-NLS-1$
                    o.put(GitConstants.KEY_COMMIT, BaseToCommitConverter.getCommitLocation(baseLocation,
                            ref.getObjectId().name(), BaseToCommitConverter.REMOVE_FIRST_3));
                    o.put(GitConstants.KEY_HEAD, BaseToCommitConverter.getCommitLocation(baseLocation,
                            Constants.HEAD, BaseToCommitConverter.REMOVE_FIRST_3));
                    o.put(GitConstants.KEY_CLONE,
                            BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.REMOTE));
                    o.put(GitConstants.KEY_BRANCH, BaseToBranchConverter.getBranchLocation(baseLocation,
                            BaseToBranchConverter.REMOTE));
                    o.put(GitConstants.KEY_INDEX,
                            BaseToIndexConverter.getIndexLocation(baseLocation, BaseToIndexConverter.REMOTE));
                    children.put(o);
                }
                result.put(ProtocolConstants.KEY_CHILDREN, children);
                OrionServlet.writeJSONResponse(request, response, result);
                return true;
            }
        }
        String msg = NLS.bind("Couldn't find remote : {0}", p.segment(0));
        return statusHandler.handleRequest(request, response,
                new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, msg, null));
    } else if (p.segment(2).equals("file")) { //$NON-NLS-1$
        // /git/remote/{remote}/{branch}/file/{path}
        File gitDir = GitUtils.getGitDir(p.removeFirstSegments(2));
        Repository db = new FileRepository(gitDir);
        Set<String> configNames = db.getConfig().getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
        URI baseLocation = getURI(request);
        for (String configName : configNames) {
            if (configName.equals(p.segment(0))) {
                for (Entry<String, Ref> refEntry : db.getRefDatabase().getRefs(Constants.R_REMOTES)
                        .entrySet()) {
                    Ref ref = refEntry.getValue();
                    String name = ref.getName();
                    if (!ref.isSymbolic()
                            && name.equals(Constants.R_REMOTES + p.uptoSegment(2).removeTrailingSeparator())) {
                        JSONObject result = new JSONObject();
                        result.put(ProtocolConstants.KEY_NAME, name.substring(Constants.R_REMOTES.length()));
                        result.put(ProtocolConstants.KEY_FULL_NAME, name);
                        result.put(ProtocolConstants.KEY_TYPE, GitConstants.REMOTE_TRACKING_BRANCH_TYPE);
                        result.put(ProtocolConstants.KEY_ID, ref.getObjectId().name());
                        // see bug 342602
                        // result.put(GitConstants.KEY_COMMIT, baseToCommitLocation(baseLocation, name));
                        result.put(ProtocolConstants.KEY_LOCATION,
                                BaseToRemoteConverter.REMOVE_FIRST_4.baseToRemoteLocation(baseLocation,
                                        "" /*short name is {remote}/{branch}*/, //$NON-NLS-1$
                                        Repository.shortenRefName(name)));
                        result.put(GitConstants.KEY_COMMIT, BaseToCommitConverter.getCommitLocation(
                                baseLocation, ref.getObjectId().name(), BaseToCommitConverter.REMOVE_FIRST_4));
                        result.put(GitConstants.KEY_HEAD, BaseToCommitConverter.getCommitLocation(baseLocation,
                                Constants.HEAD, BaseToCommitConverter.REMOVE_FIRST_4));
                        result.put(GitConstants.KEY_CLONE, BaseToCloneConverter.getCloneLocation(baseLocation,
                                BaseToCloneConverter.REMOTE_BRANCH));
                        OrionServlet.writeJSONResponse(request, response, result);
                        return true;
                    }
                }
            }
        }
        JSONObject errorData = new JSONObject();
        errorData.put(GitConstants.KEY_CLONE,
                BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.REMOTE_BRANCH));

        return statusHandler
                .handleRequest(request, response,
                        new ServerStatus(
                                new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE,
                                        "No remote branch found: "
                                                + p.uptoSegment(2).removeTrailingSeparator()),
                                HttpServletResponse.SC_NOT_FOUND, errorData));
    }
    return statusHandler.handleRequest(request, response,
            new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST,
                    "Bad request, \"/git/remote/{remote}/{branch}/file/{path}\" expected", null));
}