private void fetch(Transport transport, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (FetchConnection conn = transport.openFetch()) { Map<String, Ref> remoteRefs = conn.getRefsMap(); req.setRefs(remoteRefs); List<Ref> want = new ArrayList<>(); for (String name : req.getWantRefs()) { Ref ref = remoteRefs.get(name); if (ref != null && ref.getObjectId() != null) { want.add(ref); } } for (ObjectId id : req.getWantObjects()) { want.add(new ObjectIdRef.Unpeeled(NETWORK, id.name(), id)); } conn.fetch(NullProgressMonitor.INSTANCE, want, Collections.<ObjectId> emptySet()); } }
private void reopenConnection() throws NotSupportedException, TransportException { if (conn != null) return; conn = transport.openFetch(); // Since we opened a new connection we cannot be certain // that the system we connected to has the same exact set // of objects available (think round-robin DNS and mirrors // that aren't updated at the same time). // // We rebuild our askFor list using only the refs that the // new connection has offered to us. // final HashMap<ObjectId, Ref> avail = new HashMap<>(); for (Ref r : conn.getRefs()) avail.put(r.getObjectId(), r); final Collection<Ref> wants = new ArrayList<>(askFor.values()); askFor.clear(); for (Ref want : wants) { final Ref newRef = avail.get(want.getObjectId()); if (newRef != null) { askFor.put(newRef.getObjectId(), newRef); } else { removeFetchHeadRecord(want.getObjectId()); removeTrackingRefUpdate(want.getObjectId()); } } }
/** {@inheritDoc} */ @Override protected TransportException noRepository() { // Sadly we cannot tell the "invalid URI" case from "push not allowed". // Opening a fetch connection can help us tell the difference, as any // useful repository is going to support fetch if it also would allow // push. So if fetch throws NoRemoteRepositoryException we know the // URI is wrong. Otherwise we can correctly state push isn't allowed // as the fetch connection opened successfully. // try { transport.openFetch().close(); } catch (NotSupportedException e) { // Fall through. } catch (NoRemoteRepositoryException e) { // Fetch concluded the repository doesn't exist. // return e; } catch (TransportException e) { // Fall through. } return new TransportException(uri, JGitText.get().pushNotPermitted); }
Collection<Ref> refs; Map<String, Ref> refmap = new HashMap<>(); try (FetchConnection fc = transport.openFetch()) { refs = fc.getRefs(); if (refSpecs.isEmpty())
private void executeImp(final ProgressMonitor monitor, final FetchResult result) throws NotSupportedException, TransportException { conn = transport.openFetch(); try { result.setAdvertisedRefs(transport.getURI(), conn.getRefsMap());
private void fetch(Transport transport, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (FetchConnection conn = transport.openFetch()) { Map<String, Ref> remoteRefs = conn.getRefsMap(); req.setRefs(remoteRefs); List<Ref> want = new ArrayList<>(); for (String name : req.getWantRefs()) { Ref ref = remoteRefs.get(name); if (ref != null && ref.getObjectId() != null) { want.add(ref); } } for (ObjectId id : req.getWantObjects()) { want.add(new ObjectIdRef.Unpeeled(NETWORK, id.name(), id)); } conn.fetch(NullProgressMonitor.INSTANCE, want, Collections.<ObjectId> emptySet()); } }
private void reopenConnection() throws NotSupportedException, TransportException { if (conn != null) return; conn = transport.openFetch(); // Since we opened a new connection we cannot be certain // that the system we connected to has the same exact set // of objects available (think round-robin DNS and mirrors // that aren't updated at the same time). // // We rebuild our askFor list using only the refs that the // new connection has offered to us. // final HashMap<ObjectId, Ref> avail = new HashMap<ObjectId, Ref>(); for (final Ref r : conn.getRefs()) avail.put(r.getObjectId(), r); final Collection<Ref> wants = new ArrayList<Ref>(askFor.values()); askFor.clear(); for (final Ref want : wants) { final Ref newRef = avail.get(want.getObjectId()); if (newRef != null) { askFor.put(newRef.getObjectId(), newRef); } else { removeFetchHeadRecord(want.getObjectId()); removeTrackingRefUpdate(want.getObjectId()); } } }
private void reopenConnection() throws NotSupportedException, TransportException { if (conn != null) return; conn = transport.openFetch(); // Since we opened a new connection we cannot be certain // that the system we connected to has the same exact set // of objects available (think round-robin DNS and mirrors // that aren't updated at the same time). // // We rebuild our askFor list using only the refs that the // new connection has offered to us. // final HashMap<ObjectId, Ref> avail = new HashMap<>(); for (Ref r : conn.getRefs()) avail.put(r.getObjectId(), r); final Collection<Ref> wants = new ArrayList<>(askFor.values()); askFor.clear(); for (Ref want : wants) { final Ref newRef = avail.get(want.getObjectId()); if (newRef != null) { askFor.put(newRef.getObjectId(), newRef); } else { removeFetchHeadRecord(want.getObjectId()); removeTrackingRefUpdate(want.getObjectId()); } } }
private void fetch(Transport transport, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (FetchConnection conn = transport.openFetch()) { Map<String, Ref> remoteRefs = conn.getRefsMap(); req.setRefs(remoteRefs); List<Ref> want = new ArrayList<>(); for (String name : req.getWantRefs()) { Ref ref = remoteRefs.get(name); if (ref != null && ref.getObjectId() != null) { want.add(ref); } } for (ObjectId id : req.getWantObjects()) { want.add(new ObjectIdRef.Unpeeled(NETWORK, id.name(), id)); } conn.fetch(NullProgressMonitor.INSTANCE, want, Collections.<ObjectId> emptySet()); } }
try (Transport transport = Transport.open(repo, url)) { transport.setCredentialsProvider(getProvider()); try (FetchConnection fc = transport.openFetch()) { fc.getRefs(); if (fc instanceof BasePackFetchConnection) {
@Override protected TransportException noRepository() { // Sadly we cannot tell the "invalid URI" case from "push not allowed". // Opening a fetch connection can help us tell the difference, as any // useful repository is going to support fetch if it also would allow // push. So if fetch throws NoRemoteRepositoryException we know the // URI is wrong. Otherwise we can correctly state push isn't allowed // as the fetch connection opened successfully. // try { transport.openFetch().close(); } catch (NotSupportedException e) { // Fall through. } catch (NoRemoteRepositoryException e) { // Fetch concluded the repository doesn't exist. // return e; } catch (TransportException e) { // Fall through. } return new TransportException(uri, JGitText.get().pushNotPermitted); }
private Set<String> listRemoteBranches(String remote) throws NotSupportedException, TransportException, URISyntaxException { Set<String> branches = new HashSet<>(); try (final Repository repo = getRepository()) { StoredConfig config = repo.getConfig(); try (final Transport tn = Transport.open(repo, new URIish(config.getString("remote",remote,"url")))) { tn.setCredentialsProvider(getProvider()); try (final FetchConnection c = tn.openFetch()) { for (final Ref r : c.getRefs()) { if (r.getName().startsWith(R_HEADS)) branches.add("refs/remotes/"+remote+"/"+r.getName().substring(R_HEADS.length())); } } } } return branches; }
/** {@inheritDoc} */ @Override protected TransportException noRepository() { // Sadly we cannot tell the "invalid URI" case from "push not allowed". // Opening a fetch connection can help us tell the difference, as any // useful repository is going to support fetch if it also would allow // push. So if fetch throws NoRemoteRepositoryException we know the // URI is wrong. Otherwise we can correctly state push isn't allowed // as the fetch connection opened successfully. // try { transport.openFetch().close(); } catch (NotSupportedException e) { // Fall through. } catch (NoRemoteRepositoryException e) { // Fetch concluded the repository doesn't exist. // return e; } catch (TransportException e) { // Fall through. } return new TransportException(uri, JGitText.get().pushNotPermitted); }
Collection<Ref> refs; Map<String, Ref> refmap = new HashMap<String, Ref>(); try (FetchConnection fc = transport.openFetch()) { refs = fc.getRefs(); if (refSpecs.isEmpty())
Collection<Ref> refs; Map<String, Ref> refmap = new HashMap<>(); try (FetchConnection fc = transport.openFetch()) { refs = fc.getRefs(); if (refSpecs.isEmpty())
/** {@inheritDoc} */ @Override public ObjectId getHeadRev(String remoteRepoUrl, String branchSpec) throws GitException { try (Repository repo = openDummyRepository(); final Transport tn = Transport.open(repo, new URIish(remoteRepoUrl))) { final String branchName = extractBranchNameFromBranchSpec(branchSpec); String regexBranch = createRefRegexFromGlob(branchName); tn.setCredentialsProvider(getProvider()); try (FetchConnection c = tn.openFetch()) { for (final Ref r : c.getRefs()) { if (r.getName().matches(regexBranch)) { return r.getPeeledObjectId() != null ? r.getPeeledObjectId() : r.getObjectId(); } } } } catch (IOException | URISyntaxException | IllegalStateException e) { throw new GitException(e); } return null; }
private void executeImp(final ProgressMonitor monitor, final FetchResult result) throws NotSupportedException, TransportException { conn = transport.openFetch(); try { result.setAdvertisedRefs(transport.getURI(), conn.getRefsMap());
@Override protected void run() throws Exception { final Transport tn = Transport.open(db, remote); if (0 <= timeout) tn.setTimeout(timeout); final FetchConnection c = tn.openFetch(); try { for (final Ref r : c.getRefs()) { show(r.getObjectId(), r.getName()); if (r.getPeeledObjectId() != null) show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$ } } finally { c.close(); tn.close(); } }
private void executeImp(final ProgressMonitor monitor, final FetchResult result) throws NotSupportedException, TransportException { conn = transport.openFetch(); try { result.setAdvertisedRefs(transport.getURI(), conn.getRefsMap());