summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-12-04 17:07:10 -0800
committerJunio C Hamano <gitster@pobox.com>2007-12-04 17:07:10 -0800
commit9bbe6db85f368fc4f75cc9f6c4bfaf2269bf0068 (patch)
treed626f21e0b87a364d213d3fba26cc92d9fb5a3f6 /remote.c
parentf64c81d4282b1dacf2cf095bfb0f7708b99b3ecf (diff)
parent605b4978a105e2f40a353513f616be7d20f91c15 (diff)
downloadgit-9bbe6db85f368fc4f75cc9f6c4bfaf2269bf0068.tar.gz
Merge branch 'sp/refspec-match'
* sp/refspec-match: refactor fetch's ref matching to use refname_match() push: use same rules as git-rev-parse to resolve refspecs add refname_match() push: support pushing HEAD to real branch name
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/remote.c b/remote.c
index 46e5f04243..3fb0f99b29 100644
--- a/remote.c
+++ b/remote.c
@@ -419,25 +419,6 @@ int remote_has_url(struct remote *remote, const char *url)
return 0;
}
-/*
- * Returns true if, under the matching rules for fetching, name is the
- * same as the given full name.
- */
-static int ref_matches_abbrev(const char *name, const char *full)
-{
- if (!prefixcmp(name, "refs/") || !strcmp(name, "HEAD"))
- return !strcmp(name, full);
- if (prefixcmp(full, "refs/"))
- return 0;
- if (!prefixcmp(name, "heads/") ||
- !prefixcmp(name, "tags/") ||
- !prefixcmp(name, "remotes/"))
- return !strcmp(name, full + 5);
- if (prefixcmp(full + 5, "heads/"))
- return 0;
- return !strcmp(full + 11, name);
-}
-
int remote_find_tracking(struct remote *remote, struct refspec *refspec)
{
int find_src = refspec->src == NULL;
@@ -533,10 +514,7 @@ static int count_refspec_match(const char *pattern,
char *name = refs->name;
int namelen = strlen(name);
- if (namelen < patlen ||
- memcmp(name + namelen - patlen, pattern, patlen))
- continue;
- if (namelen != patlen && name[namelen - patlen - 1] != '/')
+ if (!refname_match(pattern, name, ref_rev_parse_rules))
continue;
/* A match is "weak" if it is with refs outside
@@ -818,7 +796,7 @@ int branch_merge_matches(struct branch *branch,
{
if (!branch || i < 0 || i >= branch->merge_nr)
return 0;
- return ref_matches_abbrev(branch->merge[i]->src, refname);
+ return refname_match(branch->merge[i]->src, refname, ref_fetch_rules);
}
static struct ref *get_expanded_map(const struct ref *remote_refs,
@@ -857,7 +835,7 @@ static const struct ref *find_ref_by_name_abbrev(const struct ref *refs, const c
{
const struct ref *ref;
for (ref = refs; ref; ref = ref->next) {
- if (ref_matches_abbrev(name, ref->name))
+ if (refname_match(name, ref->name, ref_fetch_rules))
return ref;
}
return NULL;