MCPcopy Create free account
hub / github.com/git/git / refspec_find_match

Function refspec_find_match

refspec.c:434–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434int refspec_find_match(struct refspec *rs, struct refspec_item *query)
435{
436 int i;
437 int find_src = !query->src;
438 const char *needle = find_src ? query->dst : query->src;
439 char **result = find_src ? &query->src : &query->dst;
440
441 if (find_src && !query->dst)
442 BUG("refspec_find_match: need either src or dst");
443
444 if (refspec_find_negative_match(rs, query))
445 return -1;
446
447 for (i = 0; i < rs->nr; i++) {
448 struct refspec_item *refspec = &rs->items[i];
449 const char *key = find_src ? refspec->dst : refspec->src;
450 const char *value = find_src ? refspec->src : refspec->dst;
451
452 if (!refspec->dst || refspec->negative)
453 continue;
454 if (refspec->pattern) {
455 if (match_refname_with_pattern(key, needle, value, result)) {
456 query->force = refspec->force;
457 return 0;
458 }
459 } else if (!strcmp(needle, key)) {
460 *result = xstrdup(value);
461 query->force = refspec->force;
462 return 0;
463 }
464 }
465 return -1;
466}
467
468struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs)
469{

Callers 3

apply_refspecsFunction · 0.85
remote_find_trackingFunction · 0.85
refspec_append_mappedFunction · 0.85

Calls 3

xstrdupFunction · 0.85

Tested by

no test coverage detected