From: Junio C Hamano Date: Fri, 21 Jun 2013 18:53:25 GMT Subject: Re: [PATCH 3/3] remote: don't prune when detecting overlapping refspecs Message-ID: <7v4ncrmh22.fsf@alter.siamese.dyndns.org> In-Reply-To: <1371809051-29988-4-git-send-email-dennis@kaarsemaker.net> Dennis Kaarsemaker writes: > +static int check_overlapping_remotes(struct remote *first, void *priv) { > + struct remote *second = priv; > + int i, j; > + if(!second) > + return for_each_remote(check_overlapping_remotes, first); > + if(first == second) > + return 0; > + for (i = 0; i < first->fetch_refspec_nr; i++) { > + for (j = 0; j < second->fetch_refspec_nr; j++) { > + if(strcmp(first->fetch[i].dst, second->fetch[j].dst) && > + (!fnmatch(first->fetch[i].dst, second->fetch[j].dst, 0) || > + !fnmatch(second->fetch[j].dst, first->fetch[i].dst, 0))) { > + warning(_("Overlapping refspecs detected: '%s' and '%s', not pruning."), > + first->fetch[i].dst, second->fetch[j].dst); > + return 1; > + } > + } > + } > + return 0; > +} This codepath essentially needs the same logic as 1/3, no? Instead of open code the inner loop here, can't you call the "check RHS of a single fetch refspec for overlap with refspecs from a remote" helper you introduced in 1/3? The logic in the inner loop shares the same issue as the code in 1/3; it needs to be extended to cover non-wildcard respecs and non-storing refspecs.