/** * Expand this specification to exactly match a ref. * <p> * Callers must first verify the passed ref matches this specification, * otherwise expansion results may be unpredictable. * * @param r * a ref that matched our destination specification. * @return a new specification expanded from provided ref name. Result * specification is wildcard if and only if provided ref name is * wildcard. * @throws java.lang.IllegalStateException * when the RefSpec was constructed with wildcard mode that * doesn't require matching wildcards. */ public RefSpec expandFromDestination(Ref r) { return expandFromDestination(r.getName()); }
private void deleteStaleTrackingRefs(FetchResult result, BatchRefUpdate batch) throws IOException { Set<Ref> processed = new HashSet<>(); for (Ref ref : localRefs().values()) { if (ref.isSymbolic()) { continue; } String refname = ref.getName(); for (RefSpec spec : toFetch) { if (spec.matchDestination(refname)) { RefSpec s = spec.expandFromDestination(refname); if (result.getAdvertisedRef(s.getSource()) == null && processed.add(ref)) { deleteTrackingRef(result, batch, s, ref); } } } } }
/** * Expand this specification to exactly match a ref. * <p> * Callers must first verify the passed ref matches this specification, * otherwise expansion results may be unpredictable. * * @param r * a ref that matched our destination specification. * @return a new specification expanded from provided ref name. Result * specification is wildcard if and only if provided ref name is * wildcard. * @throws IllegalStateException * when the RefSpec was constructed with wildcard mode that * doesn't require matching wildcards. */ public RefSpec expandFromDestination(final Ref r) { return expandFromDestination(r.getName()); }
/** * Expand this specification to exactly match a ref. * <p> * Callers must first verify the passed ref matches this specification, * otherwise expansion results may be unpredictable. * * @param r * a ref that matched our destination specification. * @return a new specification expanded from provided ref name. Result * specification is wildcard if and only if provided ref name is * wildcard. * @throws java.lang.IllegalStateException * when the RefSpec was constructed with wildcard mode that * doesn't require matching wildcards. */ public RefSpec expandFromDestination(Ref r) { return expandFromDestination(r.getName()); }
private void deleteStaleTrackingRefs(FetchResult result, BatchRefUpdate batch) throws IOException { Set<Ref> processed = new HashSet<>(); for (Ref ref : localRefs().values()) { if (ref.isSymbolic()) { continue; } String refname = ref.getName(); for (RefSpec spec : toFetch) { if (spec.matchDestination(refname)) { RefSpec s = spec.expandFromDestination(refname); if (result.getAdvertisedRef(s.getSource()) == null && processed.add(ref)) { deleteTrackingRef(result, batch, s, ref); } } } } }
private void deleteStaleTrackingRefs(FetchResult result, BatchRefUpdate batch) throws IOException { for (final Ref ref : localRefs().values()) { final String refname = ref.getName(); for (final RefSpec spec : toFetch) { if (spec.matchDestination(refname)) { final RefSpec s = spec.expandFromDestination(refname); if (result.getAdvertisedRef(s.getSource()) == null) { deleteTrackingRef(result, batch, s, ref); } } } } }
private void addBranchItemsForRemote(String remote) throws IOException, URISyntaxException { RemoteConfig remoteConfig = new RemoteConfig(myConfig, remote); List<RefSpec> fetchSpecs = remoteConfig.getFetchRefSpecs(); if (fetchSpecs.isEmpty()) { return; } Collection<Ref> allRefs = myRepository.getRefDatabase() .getRefs(Constants.R_REFS).values(); for (Ref ref : allRefs) { for (RefSpec fetchSpec : fetchSpecs) { // Fetch specs map remote ref names (source) to local ref names // (destination). We want to get remote ref names, so expand // destination to source. if (fetchSpec.matchDestination(ref)) { RefSpec source = fetchSpec.expandFromDestination(ref); String refNameOnRemote = source.getSource(); branchText.add(refNameOnRemote); } } } }