#include "worktree.h"
struct tracking {
- struct refspec spec;
+ struct refspec_item spec;
char *src;
const char *remote;
int matches;
static int check_tracking_branch(struct remote *remote, void *cb_data)
{
char *tracking_branch = cb_data;
- struct refspec query;
- memset(&query, 0, sizeof(struct refspec));
+ struct refspec_item query;
+ memset(&query, 0, sizeof(struct refspec_item));
query.dst = tracking_branch;
return !remote_find_tracking(remote, &query);
}
}
static struct ref *wanted_peer_refs(const struct ref *refs,
- struct refspec *refspec)
+ struct refspec_item *refspec)
{
struct ref *head = copy_ref(find_ref_by_name(refs, "HEAD"));
struct ref *local_refs = head;
int err = 0, complete_refs_before_fetch = 1;
int submodule_progress;
- struct refspec *refspec;
+ struct refspec_item *refspec;
const char *fetch_pattern;
fetch_if_missing = 0;
static int no_data;
static int full_tree;
static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
-static struct refspec *refspecs;
+static struct refspec_item *refspecs;
static int refspecs_nr;
static int anonymize;
{
int i;
for (i = 0; i < refspecs_nr; i++) {
- struct refspec *refspec = &refspecs[i];
+ struct refspec_item *refspec = &refspecs[i];
if (*refspec->src)
continue;
for (i = 0; i < branch->merge_nr; i++) {
struct ref *rm, **old_tail = *tail;
- struct refspec refspec;
+ struct refspec_item refspec;
for (rm = *head; rm; rm = rm->next) {
if (branch_merge_matches(branch, i, rm->name)) {
}
static struct ref *get_ref_map(struct transport *transport,
- struct refspec *refspecs, int refspec_count,
+ struct refspec_item *refspecs, int refspec_count,
int tags, int *autotags)
{
int i;
argv_array_clear(&ref_prefixes);
if (refspec_count) {
- struct refspec *fetch_refspec;
+ struct refspec_item *fetch_refspec;
int fetch_refspec_nr;
for (i = 0; i < refspec_count; i++) {
return ret;
}
-static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
+static int prune_refs(struct refspec_item *refs, int ref_count, struct ref *ref_map,
const char *raw_url)
{
int url_len, i, result = 0;
}
static int do_fetch(struct transport *transport,
- struct refspec *refs, int ref_count)
+ struct refspec_item *refs, int ref_count)
{
struct string_list existing_refs = STRING_LIST_INIT_DUP;
struct ref *ref_map;
static int fetch_one(struct remote *remote, int argc, const char **argv, int prune_tags_ok)
{
static const char **refs = NULL;
- struct refspec *refspec;
+ struct refspec_item *refspec;
int ref_nr = 0;
int j = 0;
int exit_code;
*/
static const char *get_tracking_branch(const char *remote, const char *refspec)
{
- struct refspec *spec;
+ struct refspec_item *spec;
const char *spec_src;
const char *merge_branch;
return ref;
if (remote->push) {
- struct refspec query;
- memset(&query, 0, sizeof(struct refspec));
+ struct refspec_item query;
+ memset(&query, 0, sizeof(struct refspec_item));
query.src = matched->name;
if (!query_refspecs(remote->push, remote->push_refspec_nr, &query) &&
query.dst) {
info->dest = xstrdup(item->string);
}
for (i = 0; i < remote->push_refspec_nr; i++) {
- struct refspec *spec = remote->push + i;
+ struct refspec_item *spec = remote->push + i;
if (spec->matching)
item = string_list_append(&states->push, _("(matching)"));
else if (strlen(spec->src))
{
struct ref *ref, *matches;
struct ref *fetch_map = NULL, **fetch_map_tail = &fetch_map;
- struct refspec refspec;
+ struct refspec_item refspec;
refspec.force = 0;
refspec.pattern = 1;
const struct object_id *oid, int flags, void *cb_data)
{
struct branches_for_remote *branches = cb_data;
- struct refspec refspec;
+ struct refspec_item refspec;
struct known_remote *kr;
memset(&refspec, 0, sizeof(refspec));
const struct object_id *oid, int flags, void *cb_data)
{
struct ref_states *states = cb_data;
- struct refspec refspec;
+ struct refspec_item refspec;
if (flags & REF_ISSYMREF)
return 0;
if (argc > 2) {
int i, refspec_nr = argc - 2;
struct ref *local_refs = get_local_heads();
- struct refspec *refspec = parse_push_refspec(refspec_nr,
+ struct refspec_item *refspec = parse_push_refspec(refspec_nr,
argv + 2);
for (i = 0; i < refspec_nr; i++) {
- struct refspec *rs = refspec + i;
+ struct refspec_item *rs = refspec + i;
if (rs->pattern || rs->matching)
continue;
static int check_tracking_name(struct remote *remote, void *cb_data)
{
struct tracking_name_data *cb = cb_data;
- struct refspec query;
- memset(&query, 0, sizeof(struct refspec));
+ struct refspec_item query;
+ memset(&query, 0, sizeof(struct refspec_item));
query.src = cb->src_ref;
if (remote_find_tracking(remote, &query) ||
get_oid(query.dst, cb->dst_oid)) {
#include "refs.h"
#include "refspec.h"
-static struct refspec s_tag_refspec = {
+static struct refspec_item s_tag_refspec = {
0,
1,
0,
};
/* See TAG_REFSPEC for the string version */
-const struct refspec *tag_refspec = &s_tag_refspec;
+const struct refspec_item *tag_refspec = &s_tag_refspec;
-static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify)
+static struct refspec_item *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify)
{
int i;
- struct refspec *rs = xcalloc(nr_refspec, sizeof(*rs));
+ struct refspec_item *rs = xcalloc(nr_refspec, sizeof(*rs));
for (i = 0; i < nr_refspec; i++) {
size_t llen;
int valid_fetch_refspec(const char *fetch_refspec_str)
{
- struct refspec *refspec;
+ struct refspec_item *refspec;
refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1);
free_refspec(1, refspec);
return !!refspec;
}
-struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec)
+struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec)
{
return parse_refspec_internal(nr_refspec, refspec, 1, 0);
}
-struct refspec *parse_push_refspec(int nr_refspec, const char **refspec)
+struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec)
{
return parse_refspec_internal(nr_refspec, refspec, 0, 0);
}
-void free_refspec(int nr_refspec, struct refspec *refspec)
+void free_refspec(int nr_refspec, struct refspec_item *refspec)
{
int i;
#define REFSPEC_H
#define TAG_REFSPEC "refs/tags/*:refs/tags/*"
-extern const struct refspec *tag_refspec;
+extern const struct refspec_item *tag_refspec;
-struct refspec {
+struct refspec_item {
unsigned force : 1;
unsigned pattern : 1;
unsigned matching : 1;
};
int valid_fetch_refspec(const char *refspec);
-struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
-struct refspec *parse_push_refspec(int nr_refspec, const char **refspec);
+struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec);
+struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec);
-void free_refspec(int nr_refspec, struct refspec *refspec);
+void free_refspec(int nr_refspec, struct refspec_item *refspec);
#endif /* REFSPEC_H */
{
int nr = remote->fetch_refspec_nr;
int bufsize = nr + 1;
- int size = sizeof(struct refspec);
+ int size = sizeof(struct refspec_item);
remote->fetch = xrealloc(remote->fetch, size * bufsize);
memcpy(&remote->fetch[nr], tag_refspec, size);
return ret;
}
-static void query_refspecs_multiple(struct refspec *refs, int ref_count, struct refspec *query, struct string_list *results)
+static void query_refspecs_multiple(struct refspec_item *refs, int ref_count, struct refspec_item *query, struct string_list *results)
{
int i;
int find_src = !query->src;
error("query_refspecs_multiple: need either src or dst");
for (i = 0; i < ref_count; i++) {
- struct refspec *refspec = &refs[i];
+ struct refspec_item *refspec = &refs[i];
const char *key = find_src ? refspec->dst : refspec->src;
const char *value = find_src ? refspec->src : refspec->dst;
const char *needle = find_src ? query->dst : query->src;
}
}
-int query_refspecs(struct refspec *refs, int ref_count, struct refspec *query)
+int query_refspecs(struct refspec_item *refs, int ref_count, struct refspec_item *query)
{
int i;
int find_src = !query->src;
return error("query_refspecs: need either src or dst");
for (i = 0; i < ref_count; i++) {
- struct refspec *refspec = &refs[i];
+ struct refspec_item *refspec = &refs[i];
const char *key = find_src ? refspec->dst : refspec->src;
const char *value = find_src ? refspec->src : refspec->dst;
return -1;
}
-char *apply_refspecs(struct refspec *refspecs, int nr_refspec,
+char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
const char *name)
{
- struct refspec query;
+ struct refspec_item query;
- memset(&query, 0, sizeof(struct refspec));
+ memset(&query, 0, sizeof(struct refspec_item));
query.src = (char *)name;
if (query_refspecs(refspecs, nr_refspec, &query))
return query.dst;
}
-int remote_find_tracking(struct remote *remote, struct refspec *refspec)
+int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
{
return query_refspecs(remote->fetch, remote->fetch_refspec_nr, refspec);
}
}
static int match_explicit_lhs(struct ref *src,
- struct refspec *rs,
+ struct refspec_item *rs,
struct ref **match,
int *allocated_match)
{
static int match_explicit(struct ref *src, struct ref *dst,
struct ref ***dst_tail,
- struct refspec *rs)
+ struct refspec_item *rs)
{
struct ref *matched_src, *matched_dst;
int allocated_src;
}
static int match_explicit_refs(struct ref *src, struct ref *dst,
- struct ref ***dst_tail, struct refspec *rs,
+ struct ref ***dst_tail, struct refspec_item *rs,
int rs_nr)
{
int i, errs;
return errs;
}
-static char *get_ref_match(const struct refspec *rs, int rs_nr, const struct ref *ref,
- int send_mirror, int direction, const struct refspec **ret_pat)
+static char *get_ref_match(const struct refspec_item *rs, int rs_nr, const struct ref *ref,
+ int send_mirror, int direction, const struct refspec_item **ret_pat)
{
- const struct refspec *pat;
+ const struct refspec_item *pat;
char *name;
int i;
int matching_refs = -1;
*/
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
{
- struct refspec *refspec = parse_push_refspec(nr_refspec, refspec_names);
+ struct refspec_item *refspec = parse_push_refspec(nr_refspec, refspec_names);
int ret = 0;
int i;
for (i = 0; i < nr_refspec; i++) {
- struct refspec *rs = refspec + i;
+ struct refspec_item *rs = refspec + i;
if (rs->pattern || rs->matching)
continue;
int match_push_refs(struct ref *src, struct ref **dst,
int nr_refspec, const char **refspec, int flags)
{
- struct refspec *rs;
+ struct refspec_item *rs;
int send_all = flags & MATCH_REFS_ALL;
int send_mirror = flags & MATCH_REFS_MIRROR;
int send_prune = flags & MATCH_REFS_PRUNE;
for (ref = src; ref; ref = ref->next) {
struct string_list_item *dst_item;
struct ref *dst_peer;
- const struct refspec *pat = NULL;
+ const struct refspec_item *pat = NULL;
char *dst_name;
dst_name = get_ref_match(rs, nr_refspec, ref, send_mirror, FROM_SRC, &pat);
* local symbolic ref.
*/
static struct ref *get_expanded_map(const struct ref *remote_refs,
- const struct refspec *refspec)
+ const struct refspec_item *refspec)
{
const struct ref *ref;
struct ref *ret = NULL;
}
int get_fetch_map(const struct ref *remote_refs,
- const struct refspec *refspec,
+ const struct refspec_item *refspec,
struct ref ***tail,
int missing_ok)
{
struct stale_heads_info {
struct string_list *ref_names;
struct ref **stale_refs_tail;
- struct refspec *refs;
+ struct refspec_item *refs;
int ref_count;
};
{
struct stale_heads_info *info = cb_data;
struct string_list matches = STRING_LIST_INIT_DUP;
- struct refspec query;
+ struct refspec_item query;
int i, stale = 1;
- memset(&query, 0, sizeof(struct refspec));
+ memset(&query, 0, sizeof(struct refspec_item));
query.dst = (char *)refname;
query_refspecs_multiple(info->refs, info->ref_count, &query, &matches);
return 0;
}
-struct ref *get_stale_heads(struct refspec *refs, int ref_count, struct ref *fetch_map)
+struct ref *get_stale_heads(struct refspec_item *refs, int ref_count, struct ref *fetch_map)
{
struct ref *ref, *stale_refs = NULL;
struct string_list ref_names = STRING_LIST_INIT_NODUP;
int pushurl_alloc;
const char **push_refspec;
- struct refspec *push;
+ struct refspec_item *push;
int push_refspec_nr;
int push_refspec_alloc;
const char **fetch_refspec;
- struct refspec *fetch;
+ struct refspec_item *fetch;
int fetch_refspec_nr;
int fetch_refspec_alloc;
*/
struct ref *ref_remove_duplicates(struct ref *ref_map);
-extern int query_refspecs(struct refspec *specs, int nr, struct refspec *query);
-char *apply_refspecs(struct refspec *refspecs, int nr_refspec,
+extern int query_refspecs(struct refspec_item *specs, int nr, struct refspec_item *query);
+char *apply_refspecs(struct refspec_item *refspecs, int nr_refspec,
const char *name);
int check_push_refs(struct ref *src, int nr_refspec, const char **refspec);
* missing_ok is usually false, but when we are adding branch.$name.merge
* it is Ok if the branch is not at the remote anymore.
*/
-int get_fetch_map(const struct ref *remote_refs, const struct refspec *refspec,
+int get_fetch_map(const struct ref *remote_refs, const struct refspec_item *refspec,
struct ref ***tail, int missing_ok);
struct ref *get_remote_ref(const struct ref *remote_refs, const char *name);
/*
* For the given remote, reads the refspec's src and sets the other fields.
*/
-int remote_find_tracking(struct remote *remote, struct refspec *refspec);
+int remote_find_tracking(struct remote *remote, struct refspec_item *refspec);
struct branch {
const char *name;
const char *pushremote_name;
const char **merge_name;
- struct refspec **merge;
+ struct refspec_item **merge;
int merge_nr;
int merge_alloc;
int all);
/* Return refs which no longer exist on remote */
-struct ref *get_stale_heads(struct refspec *refs, int ref_count, struct ref *fetch_map);
+struct ref *get_stale_heads(struct refspec_item *refs, int ref_count, struct ref *fetch_map);
/*
* Compare-and-swap
char *export_marks;
char *import_marks;
/* These go from remote name (as in "list") to private name */
- struct refspec *refspecs;
+ struct refspec_item *refspecs;
int refspec_nr;
/* Transport options for fetch-pack/send-pack (should one of
* those be invoked).
void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int verbose)
{
- struct refspec rs;
+ struct refspec_item rs;
if (ref->status != REF_STATUS_OK && ref->status != REF_STATUS_UPTODATE)
return;
int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
int push_ret, ret, err;
- struct refspec *tmp_rs;
+ struct refspec_item *tmp_rs;
struct argv_array ref_prefixes = ARGV_ARRAY_INIT;
int i;