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 <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a2ac50cbfd
commit
d000414e26
@ -831,7 +831,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
|
|||||||
|
|
||||||
if (refspecs.nr) {
|
if (refspecs.nr) {
|
||||||
char *private;
|
char *private;
|
||||||
private = apply_refspecs(refspecs.items, refspecs.nr, full_name);
|
private = apply_refspecs(&refspecs, full_name);
|
||||||
if (private) {
|
if (private) {
|
||||||
free(full_name);
|
free(full_name);
|
||||||
full_name = private;
|
full_name = private;
|
||||||
|
15
remote.c
15
remote.c
@ -525,8 +525,7 @@ const char *remote_ref_for_branch(struct branch *branch, int for_push,
|
|||||||
struct remote *remote = remote_get(remote_name);
|
struct remote *remote = remote_get(remote_name);
|
||||||
|
|
||||||
if (remote && remote->push.nr &&
|
if (remote && remote->push.nr &&
|
||||||
(dst = apply_refspecs(remote->push.items,
|
(dst = apply_refspecs(&remote->push,
|
||||||
remote->push.nr,
|
|
||||||
branch->refname))) {
|
branch->refname))) {
|
||||||
if (explicit)
|
if (explicit)
|
||||||
*explicit = 1;
|
*explicit = 1;
|
||||||
@ -757,15 +756,14 @@ int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
|
char *apply_refspecs(struct refspec *rs, const char *name)
|
||||||
const char *name)
|
|
||||||
{
|
{
|
||||||
struct refspec_item query;
|
struct refspec_item query;
|
||||||
|
|
||||||
memset(&query, 0, sizeof(struct refspec_item));
|
memset(&query, 0, sizeof(struct refspec_item));
|
||||||
query.src = (char *)name;
|
query.src = (char *)name;
|
||||||
|
|
||||||
if (query_refspecs(refspecs, nr_refspec, &query))
|
if (query_refspecs(rs->items, rs->nr, &query))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return query.dst;
|
return query.dst;
|
||||||
@ -1571,7 +1569,7 @@ static const char *tracking_for_push_dest(struct remote *remote,
|
|||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
ret = apply_refspecs(remote->fetch.items, remote->fetch.nr, refname);
|
ret = apply_refspecs(&remote->fetch, refname);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return error_buf(err,
|
return error_buf(err,
|
||||||
_("push destination '%s' on remote '%s' has no local tracking branch"),
|
_("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)
|
|||||||
char *dst;
|
char *dst;
|
||||||
const char *ret;
|
const char *ret;
|
||||||
|
|
||||||
dst = apply_refspecs(remote->push.items, remote->push.nr,
|
dst = apply_refspecs(&remote->push, branch->refname);
|
||||||
branch->refname);
|
|
||||||
if (!dst)
|
if (!dst)
|
||||||
return error_buf(err,
|
return error_buf(err,
|
||||||
_("push refspecs for '%s' do not include '%s'"),
|
_("push refspecs for '%s' do not include '%s'"),
|
||||||
@ -2203,7 +2200,7 @@ static int remote_tracking(struct remote *remote, const char *refname,
|
|||||||
{
|
{
|
||||||
char *dst;
|
char *dst;
|
||||||
|
|
||||||
dst = apply_refspecs(remote->fetch.items, remote->fetch.nr, refname);
|
dst = apply_refspecs(&remote->fetch, refname);
|
||||||
if (!dst)
|
if (!dst)
|
||||||
return -1; /* no tracking ref for refname at remote */
|
return -1; /* no tracking ref for refname at remote */
|
||||||
if (read_ref(dst, oid))
|
if (read_ref(dst, oid))
|
||||||
|
3
remote.h
3
remote.h
@ -159,8 +159,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
|
|||||||
struct ref *ref_remove_duplicates(struct ref *ref_map);
|
struct ref *ref_remove_duplicates(struct ref *ref_map);
|
||||||
|
|
||||||
extern int query_refspecs(struct refspec_item *specs, int nr, struct refspec_item *query);
|
extern int query_refspecs(struct refspec_item *specs, int nr, struct refspec_item *query);
|
||||||
char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
|
char *apply_refspecs(struct refspec *rs, const char *name);
|
||||||
const char *name);
|
|
||||||
|
|
||||||
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
|
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
|
||||||
int match_push_refs(struct ref *src, struct ref **dst,
|
int match_push_refs(struct ref *src, struct ref **dst,
|
||||||
|
@ -523,7 +523,7 @@ static int fetch_with_import(struct transport *transport,
|
|||||||
continue;
|
continue;
|
||||||
name = posn->symref ? posn->symref : posn->name;
|
name = posn->symref ? posn->symref : posn->name;
|
||||||
if (data->rs.nr)
|
if (data->rs.nr)
|
||||||
private = apply_refspecs(data->rs.items, data->rs.nr, name);
|
private = apply_refspecs(&data->rs, name);
|
||||||
else
|
else
|
||||||
private = xstrdup(name);
|
private = xstrdup(name);
|
||||||
if (private) {
|
if (private) {
|
||||||
@ -805,7 +805,7 @@ static int push_update_refs_status(struct helper_data *data,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* propagate back the update to the remote namespace */
|
/* propagate back the update to the remote namespace */
|
||||||
private = apply_refspecs(data->rs.items, data->rs.nr, ref->name);
|
private = apply_refspecs(&data->rs, ref->name);
|
||||||
if (!private)
|
if (!private)
|
||||||
continue;
|
continue;
|
||||||
update_ref("update by helper", private, &ref->new_oid, NULL,
|
update_ref("update by helper", private, &ref->new_oid, NULL,
|
||||||
@ -942,7 +942,7 @@ static int push_refs_with_export(struct transport *transport,
|
|||||||
char *private;
|
char *private;
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
|
|
||||||
private = apply_refspecs(data->rs.items, data->rs.nr, ref->name);
|
private = apply_refspecs(&data->rs, ref->name);
|
||||||
if (private && !get_oid(private, &oid)) {
|
if (private && !get_oid(private, &oid)) {
|
||||||
strbuf_addf(&buf, "^%s", private);
|
strbuf_addf(&buf, "^%s", private);
|
||||||
string_list_append_nodup(&revlist_args,
|
string_list_append_nodup(&revlist_args,
|
||||||
|
Reference in New Issue
Block a user