Skip to content

Commit d000414

Browse files
bmwillgitster
authored andcommitted
remote: convert apply_refspecs to take a struct refspec
Convert 'apply_refspecs()' to take a 'struct refspec' as a parameter instead of a list of 'struct refspec_item'. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a2ac50c commit d000414

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
831831

832832
if (refspecs.nr) {
833833
char *private;
834-
private = apply_refspecs(refspecs.items, refspecs.nr, full_name);
834+
private = apply_refspecs(&refspecs, full_name);
835835
if (private) {
836836
free(full_name);
837837
full_name = private;

remote.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,7 @@ const char *remote_ref_for_branch(struct branch *branch, int for_push,
525525
struct remote *remote = remote_get(remote_name);
526526

527527
if (remote && remote->push.nr &&
528-
(dst = apply_refspecs(remote->push.items,
529-
remote->push.nr,
528+
(dst = apply_refspecs(&remote->push,
530529
branch->refname))) {
531530
if (explicit)
532531
*explicit = 1;
@@ -757,15 +756,14 @@ int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item
757756
return -1;
758757
}
759758

760-
char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
761-
const char *name)
759+
char *apply_refspecs(struct refspec *rs, const char *name)
762760
{
763761
struct refspec_item query;
764762

765763
memset(&query, 0, sizeof(struct refspec_item));
766764
query.src = (char *)name;
767765

768-
if (query_refspecs(refspecs, nr_refspec, &query))
766+
if (query_refspecs(rs->items, rs->nr, &query))
769767
return NULL;
770768

771769
return query.dst;
@@ -1571,7 +1569,7 @@ static const char *tracking_for_push_dest(struct remote *remote,
15711569
{
15721570
char *ret;
15731571

1574-
ret = apply_refspecs(remote->fetch.items, remote->fetch.nr, refname);
1572+
ret = apply_refspecs(&remote->fetch, refname);
15751573
if (!ret)
15761574
return error_buf(err,
15771575
_("push destination '%s' on remote '%s' has no local tracking branch"),
@@ -1593,8 +1591,7 @@ static const char *branch_get_push_1(struct branch *branch, struct strbuf *err)
15931591
char *dst;
15941592
const char *ret;
15951593

1596-
dst = apply_refspecs(remote->push.items, remote->push.nr,
1597-
branch->refname);
1594+
dst = apply_refspecs(&remote->push, branch->refname);
15981595
if (!dst)
15991596
return error_buf(err,
16001597
_("push refspecs for '%s' do not include '%s'"),
@@ -2203,7 +2200,7 @@ static int remote_tracking(struct remote *remote, const char *refname,
22032200
{
22042201
char *dst;
22052202

2206-
dst = apply_refspecs(remote->fetch.items, remote->fetch.nr, refname);
2203+
dst = apply_refspecs(&remote->fetch, refname);
22072204
if (!dst)
22082205
return -1; /* no tracking ref for refname at remote */
22092206
if (read_ref(dst, oid))

remote.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
159159
struct ref *ref_remove_duplicates(struct ref *ref_map);
160160

161161
extern int query_refspecs(struct refspec_item *specs, int nr, struct refspec_item *query);
162-
char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
163-
const char *name);
162+
char *apply_refspecs(struct refspec *rs, const char *name);
164163

165164
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
166165
int match_push_refs(struct ref *src, struct ref **dst,

transport-helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static int fetch_with_import(struct transport *transport,
523523
continue;
524524
name = posn->symref ? posn->symref : posn->name;
525525
if (data->rs.nr)
526-
private = apply_refspecs(data->rs.items, data->rs.nr, name);
526+
private = apply_refspecs(&data->rs, name);
527527
else
528528
private = xstrdup(name);
529529
if (private) {
@@ -805,7 +805,7 @@ static int push_update_refs_status(struct helper_data *data,
805805
continue;
806806

807807
/* propagate back the update to the remote namespace */
808-
private = apply_refspecs(data->rs.items, data->rs.nr, ref->name);
808+
private = apply_refspecs(&data->rs, ref->name);
809809
if (!private)
810810
continue;
811811
update_ref("update by helper", private, &ref->new_oid, NULL,
@@ -942,7 +942,7 @@ static int push_refs_with_export(struct transport *transport,
942942
char *private;
943943
struct object_id oid;
944944

945-
private = apply_refspecs(data->rs.items, data->rs.nr, ref->name);
945+
private = apply_refspecs(&data->rs, ref->name);
946946
if (private && !get_oid(private, &oid)) {
947947
strbuf_addf(&buf, "^%s", private);
948948
string_list_append_nodup(&revlist_args,

0 commit comments

Comments
 (0)