Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 54457fe

Browse files
mhaggergitster
authored andcommitted
refname_match(): always use the rules in ref_rev_parse_rules
We used to use two separate rules for the normal ref resolution dwimming and dwimming done to decide which remote ref to grab. The third parameter to refname_match() selected which rules to use. When these two rules were harmonized in 2011-11-04 dd621df refs DWIMmery: use the same rule for both "git fetch" and others , ref_fetch_rules was #defined to avoid potential breakages for in-flight topics. It is now safe to remove the backwards-compatibility code, so remove refname_match()'s third parameter, make ref_rev_parse_rules private to refs.c, and remove ref_fetch_rules entirely. Suggested-by: Junio C Hamano <[email protected]> Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4224916 commit 54457fe

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

cache.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -887,9 +887,12 @@ extern int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);
887887
extern int interpret_branch_name(const char *str, int len, struct strbuf *);
888888
extern int get_sha1_mb(const char *str, unsigned char *sha1);
889889

890-
extern int refname_match(const char *abbrev_name, const char *full_name, const char **rules);
891-
extern const char *ref_rev_parse_rules[];
892-
#define ref_fetch_rules ref_rev_parse_rules
890+
/*
891+
* Return true iff abbrev_name is a possible abbreviation for
892+
* full_name according to the rules defined by ref_rev_parse_rules in
893+
* refs.c.
894+
*/
895+
extern int refname_match(const char *abbrev_name, const char *full_name);
893896

894897
extern int create_symref(const char *ref, const char *refs_heads_master, const char *logmsg);
895898
extern int validate_headref(const char *ref);

refs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ const char *prettify_refname(const char *name)
18801880
0);
18811881
}
18821882

1883-
const char *ref_rev_parse_rules[] = {
1883+
static const char *ref_rev_parse_rules[] = {
18841884
"%.*s",
18851885
"refs/%.*s",
18861886
"refs/tags/%.*s",
@@ -1890,12 +1890,12 @@ const char *ref_rev_parse_rules[] = {
18901890
NULL
18911891
};
18921892

1893-
int refname_match(const char *abbrev_name, const char *full_name, const char **rules)
1893+
int refname_match(const char *abbrev_name, const char *full_name)
18941894
{
18951895
const char **p;
18961896
const int abbrev_name_len = strlen(abbrev_name);
18971897

1898-
for (p = rules; *p; p++) {
1898+
for (p = ref_rev_parse_rules; *p; p++) {
18991899
if (!strcmp(full_name, mkpath(*p, abbrev_name_len, abbrev_name))) {
19001900
return 1;
19011901
}

remote.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ static int count_refspec_match(const char *pattern,
969969
char *name = refs->name;
970970
int namelen = strlen(name);
971971

972-
if (!refname_match(pattern, name, ref_rev_parse_rules))
972+
if (!refname_match(pattern, name))
973973
continue;
974974

975975
/* A match is "weak" if it is with refs outside
@@ -1540,7 +1540,7 @@ int branch_merge_matches(struct branch *branch,
15401540
{
15411541
if (!branch || i < 0 || i >= branch->merge_nr)
15421542
return 0;
1543-
return refname_match(branch->merge[i]->src, refname, ref_fetch_rules);
1543+
return refname_match(branch->merge[i]->src, refname);
15441544
}
15451545

15461546
static int ignore_symref_update(const char *refname)
@@ -1586,7 +1586,7 @@ static const struct ref *find_ref_by_name_abbrev(const struct ref *refs, const c
15861586
{
15871587
const struct ref *ref;
15881588
for (ref = refs; ref; ref = ref->next) {
1589-
if (refname_match(name, ref->name, ref_fetch_rules))
1589+
if (refname_match(name, ref->name))
15901590
return ref;
15911591
}
15921592
return NULL;
@@ -2083,7 +2083,7 @@ static void apply_cas(struct push_cas_option *cas,
20832083
/* Find an explicit --<option>=<name>[:<value>] entry */
20842084
for (i = 0; i < cas->nr; i++) {
20852085
struct push_cas *entry = &cas->entry[i];
2086-
if (!refname_match(entry->refname, ref->name, ref_rev_parse_rules))
2086+
if (!refname_match(entry->refname, ref->name))
20872087
continue;
20882088
ref->expect_old_sha1 = 1;
20892089
if (!entry->use_tracking)

0 commit comments

Comments
 (0)