Re: [PATCH 3/3] remote: don't prune when detecting overlapping refspecs
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:52
Dennis Kaarsemaker [off-list ref] 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.