X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=remote.c;h=4b5b90597999cb836979338d84d1c5d4748c96e7;hb=e4d1afbcf2e39a997ae90befd629ee53e444c4c9;hp=08a59644c03b9c61bfad8383e521ac813e0c4f05;hpb=7c74c3926ad60ba1bbfed13355f00a29813a0f32;p=git.git diff --git a/remote.c b/remote.c index 08a59644c..4b5b90597 100644 --- a/remote.c +++ b/remote.c @@ -106,6 +106,12 @@ static void add_url_alias(struct remote *remote, const char *url) add_url(remote, alias_url(url)); } +static void add_pushurl(struct remote *remote, const char *pushurl) +{ + ALLOC_GROW(remote->pushurl, remote->pushurl_nr + 1, remote->pushurl_alloc); + remote->pushurl[remote->pushurl_nr++] = pushurl; +} + static struct remote *make_remote(const char *name, int len) { struct remote *ret; @@ -301,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) @@ -312,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 */ } @@ -379,6 +385,11 @@ static int handle_config(const char *key, const char *value, void *cb) if (git_config_string(&v, key, value)) return -1; add_url(remote, v); + } else if (!strcmp(subkey, ".pushurl")) { + const char *v; + if (git_config_string(&v, key, value)) + return -1; + add_pushurl(remote, v); } else if (!strcmp(subkey, ".push")) { const char *v; if (git_config_string(&v, key, value)) @@ -424,6 +435,9 @@ static void alias_all_urls(void) for (j = 0; j < remotes[i]->url_nr; j++) { remotes[i]->url[j] = alias_url(remotes[i]->url[j]); } + for (j = 0; j < remotes[i]->pushurl_nr; j++) { + remotes[i]->pushurl[j] = alias_url(remotes[i]->pushurl[j]); + } } } @@ -1024,7 +1038,7 @@ static int match_explicit(struct ref *src, struct ref *dst, case 0: if (!memcmp(dst_value, "refs/", 5)) matched_dst = make_linked_ref(dst_value, dst_tail); - else if((dst_guess = guess_ref(dst_value, matched_src))) + else if ((dst_guess = guess_ref(dst_value, matched_src))) matched_dst = make_linked_ref(dst_guess, dst_tail); else error("unable to push to unqualified destination: %s\n" @@ -1105,7 +1119,7 @@ int match_refs(struct ref *src, struct ref **dst, 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) { @@ -1263,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/"))