From 654a7e497886cc16f6823b7d589c3ddeb178a848 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Wed, 16 Jan 2013 16:09:18 +0100 Subject: [PATCH] WIP --- builtin/remote.c | 15 ++++++++++++--- remote.c | 18 ++++++++++++------ remote.h | 8 ++++---- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/builtin/remote.c b/builtin/remote.c index fa5d1e1784..146973a456 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -1084,6 +1084,13 @@ static int show_push_info_item(struct string_list_item *item, void *cb_data) return 0; } +static const char *insteadof_or_plain(const char *fromurl) +{ + if (!fromurl) + return "(direct)"; + return fromurl; +} + static int show(int argc, const char **argv) { int no_query = 0, result = 0, query_flag = 0; @@ -1117,17 +1124,19 @@ static int show(int argc, const char **argv) printf_ln(_("* remote %s"), *argv); printf_ln(_(" URLs:")); - printf_ln(_(" Fetch: %s"), states.remote->url_nr > 0 ? - states.remote->url[0] : _("(no URL)")); + printf_ln(_(" Fetch: %s%s"), states.remote->url_nr > 0 ? + states.remote->url[0] : _("(no URL)"), insteadof_or_plain(states.remote->fromurl[0])); if (states.remote->pushurl_nr) { url = states.remote->pushurl; url_nr = states.remote->pushurl_nr; +puts("pushUrls"); } else { url = states.remote->url; url_nr = states.remote->url_nr; +puts("no pushURLs"); } for (i = 0; i < url_nr; i++) - printf_ln(_(" Push: %s"), url[i]); + printf_ln(_(" Push: %s%s"), url[i], insteadof_or_plain(states.remote->frompushurl[i])); if (!i) printf_ln(_(" Push: %s"), "(no URL)"); if (no_query) diff --git a/remote.c b/remote.c index 4b1153f02c..6d552d727e 100644 --- a/remote.c +++ b/remote.c @@ -108,28 +108,34 @@ static void add_fetch_refspec(struct remote *remote, const char *ref) remote->fetch_refspec[remote->fetch_refspec_nr++] = ref; } -static void add_url(struct remote *remote, const char *url) +static void add_url(struct remote *remote, const char *url, const char *fromurl) { ALLOC_GROW(remote->url, remote->url_nr + 1, remote->url_alloc); + ALLOC_GROW(remote->fromurl, remote->url_nr + 1, remote->fromurl_alloc); remote->url[remote->url_nr++] = url; + remote->fromurl[remote->url_nr] = fromurl; +printf("added url %s (from %s)\n", url, fromurl ? fromurl : ""); } -static void add_pushurl(struct remote *remote, const char *pushurl) +static void add_pushurl(struct remote *remote, const char *pushurl, const char *fromurl) { ALLOC_GROW(remote->pushurl, remote->pushurl_nr + 1, remote->pushurl_alloc); + ALLOC_GROW(remote->frompushurl, remote->pushurl_nr + 1, remote->frompushurl_alloc); remote->pushurl[remote->pushurl_nr++] = pushurl; + remote->frompushurl[remote->pushurl_nr] = fromurl; +printf("added pushurl %s (from %s)\n", pushurl, fromurl ? fromurl : ""); } static void add_pushurl_alias(struct remote *remote, const char *url) { const char *pushurl = alias_url(url, &rewrites_push); if (pushurl != url) - add_pushurl(remote, pushurl); + add_pushurl(remote, pushurl, url); } static void add_url_alias(struct remote *remote, const char *url) { - add_url(remote, alias_url(url, &rewrites)); + add_url(remote, alias_url(url, &rewrites), url); add_pushurl_alias(remote, url); } @@ -411,12 +417,12 @@ static int handle_config(const char *key, const char *value, void *cb) const char *v; if (git_config_string(&v, key, value)) return -1; - add_url(remote, v); + add_url(remote, v, NULL); } else if (!strcmp(subkey, ".pushurl")) { const char *v; if (git_config_string(&v, key, value)) return -1; - add_pushurl(remote, v); + add_pushurl(remote, v, NULL); } else if (!strcmp(subkey, ".push")) { const char *v; if (git_config_string(&v, key, value)) diff --git a/remote.h b/remote.h index 251d8fd965..1ac544e572 100644 --- a/remote.h +++ b/remote.h @@ -13,13 +13,13 @@ struct remote { const char *foreign_vcs; - const char **url; + const char **url, **fromurl; int url_nr; - int url_alloc; + int url_alloc, fromurl_alloc; - const char **pushurl; + const char **pushurl, **frompushurl; int pushurl_nr; - int pushurl_alloc; + int pushurl_alloc, frompushurl_alloc; const char **push_refspec; struct refspec *push; -- 2.11.4.GIT