X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=remote.c;h=c3ada2d72b9b3f7411ffe420030768e73a003923;hb=46068383aa825dfe9026f9255cea07da07e06253;hp=4544d65c72c825a1e3e71f9e1a1052f0574f2a9a;hpb=203462347fce0eab563fe77640648a7e8ae64d3b;p=git.git diff --git a/remote.c b/remote.c index 4544d65c7..c3ada2d72 100644 --- a/remote.c +++ b/remote.c @@ -307,7 +307,7 @@ static void read_branches_file(struct remote *remote) strbuf_addstr(&branch, "HEAD:"); } add_url_alias(remote, p); - add_fetch_refspec(remote, strbuf_detach(&branch, 0)); + add_fetch_refspec(remote, strbuf_detach(&branch, NULL)); /* * Cogito compatible push: push current HEAD to remote #branch * (master if missing) @@ -318,7 +318,7 @@ static void read_branches_file(struct remote *remote) strbuf_addf(&branch, ":refs/heads/%s", frag); else strbuf_addstr(&branch, ":refs/heads/master"); - add_push_refspec(remote, strbuf_detach(&branch, 0)); + add_push_refspec(remote, strbuf_detach(&branch, NULL)); remote->fetch_tags = 1; /* always auto-follow */ } @@ -1099,26 +1099,35 @@ static const struct refspec *check_pattern_match(const struct refspec *rs, return NULL; } +static struct ref **tail_ref(struct ref **head) +{ + struct ref **tail = head; + while (*tail) + tail = &((*tail)->next); + return tail; +} + /* * Note. This is used only by "push"; refspec matching rules for * push and fetch are subtly different, so do not try to reuse it * without thinking. */ -int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail, +int match_refs(struct ref *src, struct ref **dst, int nr_refspec, const char **refspec, int flags) { struct refspec *rs; int send_all = flags & MATCH_REFS_ALL; int send_mirror = flags & MATCH_REFS_MIRROR; int errs; - static const char *default_refspec[] = { ":", 0 }; + static const char *default_refspec[] = { ":", NULL }; + struct ref **dst_tail = tail_ref(dst); if (!nr_refspec) { nr_refspec = 1; refspec = default_refspec; } rs = parse_push_refspec(nr_refspec, (const char **) refspec); - errs = match_explicit_refs(src, dst, dst_tail, rs, nr_refspec); + errs = match_explicit_refs(src, *dst, &dst_tail, rs, nr_refspec); /* pick the remainder */ for ( ; src; src = src->next) { @@ -1148,7 +1157,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail, dst_side, &dst_name)) die("Didn't think it matches any more"); } - dst_peer = find_ref_by_name(dst, dst_name); + dst_peer = find_ref_by_name(*dst, dst_name); if (dst_peer) { if (dst_peer->peer_ref) /* We're already sending something to this ref. */ @@ -1164,7 +1173,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail, goto free_name; /* Create a new one and link it */ - dst_peer = make_linked_ref(dst_name, dst_tail); + dst_peer = make_linked_ref(dst_name, &dst_tail); hashcpy(dst_peer->new_sha1, src->new_sha1); } dst_peer->peer_ref = copy_ref(src); @@ -1268,7 +1277,7 @@ struct ref *get_remote_ref(const struct ref *remote_refs, const char *name) static struct ref *get_local_ref(const char *name) { - if (!name) + if (!name || name[0] == '\0') return NULL; if (!prefixcmp(name, "refs/"))