X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=builtin-push.c;h=e530022824c13138925152de716beb3573714f40;hb=cc120056a881101326488e3c5c2d3af2ce3a8de6;hp=9a861b5afea701ddaa31fba902d535710afda13d;hpb=7aaf83dafbde7aaa60a1e220e967faaeb28a46f6;p=git.git diff --git a/builtin-push.c b/builtin-push.c index 9a861b5a..e5300228 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -72,7 +72,7 @@ static int get_remotes_uri(const char *repo, const char *uri[MAX_URI]) { int n = 0; FILE *f = fopen(git_path("remotes/%s", repo), "r"); - int has_explicit_refspec = refspec_nr; + int has_explicit_refspec = refspec_nr || all || tags; if (!f) return -1; @@ -115,6 +115,41 @@ static int get_remotes_uri(const char *repo, const char *uri[MAX_URI]) return n; } +static const char **config_uri; +static const char *config_repo; +static int config_repo_len; +static int config_current_uri; +static int config_get_refspecs; + +static int get_remote_config(const char* key, const char* value) +{ + if (!strncmp(key, "remote.", 7) && + !strncmp(key + 7, config_repo, config_repo_len)) { + if (!strcmp(key + 7 + config_repo_len, ".url")) { + if (config_current_uri < MAX_URI) + config_uri[config_current_uri++] = strdup(value); + else + error("more than %d URL's specified, ignoring the rest", MAX_URI); + } + else if (config_get_refspecs && + !strcmp(key + 7 + config_repo_len, ".push")) + add_refspec(strdup(value)); + } + return 0; +} + +static int get_config_remotes_uri(const char *repo, const char *uri[MAX_URI]) +{ + config_repo_len = strlen(repo); + config_repo = repo; + config_current_uri = 0; + config_uri = uri; + config_get_refspecs = !(refspec_nr || all || tags); + + git_config(get_remote_config); + return config_current_uri; +} + static int get_branches_uri(const char *repo, const char *uri[MAX_URI]) { const char *slash = strchr(repo, '/'); @@ -162,6 +197,10 @@ static int read_config(const char *repo, const char *uri[MAX_URI]) if (n > 0) return n; + n = get_config_remotes_uri(repo, uri); + if (n > 0) + return n; + n = get_branches_uri(repo, uri); if (n > 0) return n;