Use a single function to match names against patterns
This will help when the matching changes. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Daniel Barkalow committed
Mar 7, 2009 at 01:11 UTC
a3c8423901ec4996369b137b46354ddf1cfc0e0e
1 file changed
+9
-3
remote.c
+9
-3
@@ -719,6 +719,12 @@ int remote_has_url(struct remote *remote, const char *url)
719
return 0;
720
}
721
722
+static int match_name_with_pattern(const char *key, const char *name)
723
+{
724
+ int ret = !prefixcmp(key, name);
725
+ return ret;
726
+}
727
+
728
int remote_find_tracking(struct remote *remote, struct refspec *refspec)
729
{
730
int find_src = refspec->src == NULL;
@@ -742,7 +748,7 @@ int remote_find_tracking(struct remote *remote, struct refspec *refspec)
748
if (!fetch->dst)
749
continue;
750
if (fetch->pattern) {
745
- if (!prefixcmp(needle, key)) {
751
+ if (match_name_with_pattern(key, needle)) {
752
*result = xmalloc(strlen(value) +
753
strlen(needle) -
754
strlen(key) + 1);
@@ -1020,7 +1026,7 @@ static const struct refspec *check_pattern_match(const struct refspec *rs,
1026
continue;
1027
}
1028
1023
- if (rs[i].pattern && !prefixcmp(src->name, rs[i].src))
1029
+ if (rs[i].pattern && match_name_with_pattern(rs[i].src, src->name))
1030
return rs + i;
1031
}
1032
if (matching_refs != -1)
@@ -1160,7 +1166,7 @@ static struct ref *get_expanded_map(const struct ref *remote_refs,
1166
for (ref = remote_refs; ref; ref = ref->next) {
1167
if (strchr(ref->name, '^'))
1168
continue; /* a dereference item */
1163
- if (!prefixcmp(ref->name, refspec->src)) {
1169
+ if (match_name_with_pattern(refspec->src, ref->name)) {
1170
const char *match;
1171
struct ref *cpy = copy_ref(ref);
1172
match = ref->name + remote_prefix_len;