{"thread":{"id":"39982","subject":"[PATCH] add ls-remote --get-push-url option","startedAt":"2015-07-31T17:38:40Z","lastAt":"2015-09-17T00:19:16Z","messageCount":22,"participants":["Ben Boeckel","Junio C Hamano","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"267206","messageId":"1438364321-14646-1-git-send-email-mathstuf@gmail.com","threadId":"39982","inReplyTo":null,"subject":"[PATCH] add ls-remote --get-push-url option","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-07-31T17:38:40Z","receivedAt":"2015-07-31T17:38:40Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"Not sure if it would be better to make a new variable or to reuse the existing\none. I'm reusing it currently because it makes it easier to ensure they\nare mutually exclusive.\n\nPlease keep me CC'd to the list; I'm not subscribed.\n\nThanks,\n\n--Ben\n\nBen Boeckel (1):\n  ls-remote: add --get-push-url option\n\n Documentation/git-ls-remote.txt |  7 ++++++-\n builtin/ls-remote.c             | 15 +++++++++++++--\n 2 files changed, 19 insertions(+), 3 deletions(-)\n\n-- \n2.1.0\n"},{"id":"267207","messageId":"1438364321-14646-2-git-send-email-mathstuf@gmail.com","threadId":"39982","inReplyTo":"1438364321-14646-1-git-send-email-mathstuf@gmail.com","subject":"[PATCH] ls-remote: add --get-push-url option","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-07-31T17:38:41Z","receivedAt":"2015-07-31T17:38:41Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"With pushInsteadOf and triangle workflows, a flag to have git fully\nexpand the push URL is also useful since it can be very different from\nthe --get-url output.\n\nSigned-off-by: Ben Boeckel <mathstuf@gmail.com>\n---\n Documentation/git-ls-remote.txt |  7 ++++++-\n builtin/ls-remote.c             | 15 +++++++++++++--\n 2 files changed, 19 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt\nindex 2e22915..66cda0e 100644\n--- a/Documentation/git-ls-remote.txt\n+++ b/Documentation/git-ls-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git ls-remote' [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]\n-\t      [--exit-code] <repository> [<refs>...]\n+\t      [--exit-code] [--get-url | --get-push-url] <repository> [<refs>...]\n \n DESCRIPTION\n -----------\n@@ -47,6 +47,11 @@ OPTIONS\n \t\"url.<base>.insteadOf\" config setting (See linkgit:git-config[1]) and\n \texit without talking to the remote.\n \n+--get-push-url::\n+\tExpand the URL of the given remote repository taking into account any\n+\t\"url.<base>.pushInsteadOf\" config setting (See linkgit:git-config[1])\n+\tand exit without talking to the remote.\n+\n <repository>::\n \tThe \"remote\" repository to query.  This parameter can be\n \teither a URL or the name of a remote (see the GIT URLS and\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 4554dbc..25c6f79 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -5,7 +5,7 @@\n \n static const char ls_remote_usage[] =\n \"git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]\\n\"\n-\"                     [-q | --quiet] [--exit-code] [--get-url] [<repository> [<refs>...]]\";\n+\"                     [-q | --quiet] [--exit-code] [--get-url | --get-push-url] [<repository> [<refs>...]]\";\n \n /*\n  * Is there one among the list of patterns that match the tail part\n@@ -40,6 +40,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tconst char **pattern = NULL;\n \n \tstruct remote *remote;\n+\tstruct remote *pushremote;\n \tstruct transport *transport;\n \tconst struct ref *ref;\n \n@@ -78,6 +79,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \t\t\t\tget_url = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(\"--get-push-url\", arg)) {\n+\t\t\t\tget_url = 2;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(\"--exit-code\", arg)) {\n \t\t\t\t/* return this code if no refs are reported */\n \t\t\t\tstatus = 2;\n@@ -109,9 +114,15 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tif (!remote->url_nr)\n \t\tdie(\"remote %s has no configured URL\", dest);\n \n-\tif (get_url) {\n+\tif (get_url == 1) {\n \t\tprintf(\"%s\\n\", *remote->url);\n \t\treturn 0;\n+\t} else if (get_url == 2) {\n+\t\tpushremote = pushremote_get(dest);\n+\t\tif (!pushremote->url_nr)\n+\t\t\tdie(\"remote %s has no configured push URL\", dest);\n+\t\tprintf(\"%s\\n\", *pushremote->url);\n+\t\treturn 0;\n \t}\n \n \ttransport = transport_get(remote, NULL);\n-- \n2.1.0\n"},{"id":"267210","messageId":"xmqqfv445fxv.fsf@gitster.dls.corp.google.com","threadId":"39982","inReplyTo":"1438364321-14646-1-git-send-email-mathstuf@gmail.com","subject":"Re: [PATCH] add ls-remote --get-push-url option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-31T18:40:12Z","receivedAt":"2015-07-31T18:40:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Boeckel <mathstuf@gmail.com> writes:\n\n> Not sure if it would be better to make a new variable or to reuse the existing\n> one. I'm reusing it currently because it makes it easier to ensure they\n> are mutually exclusive.\n>\n> Please keep me CC'd to the list; I'm not subscribed.\n>\n> Thanks,\n>\n> --Ben\n>\n> Ben Boeckel (1):\n>   ls-remote: add --get-push-url option\n>\n>  Documentation/git-ls-remote.txt |  7 ++++++-\n>  builtin/ls-remote.c             | 15 +++++++++++++--\n>  2 files changed, 19 insertions(+), 3 deletions(-)\n\nProbably get-url makes (some) sense because ls-remote is a \"fetch\nthat does not actually fetch anything\".  But \"get-push-url\" to\nls-remote makes _no_ sense whatsoever.  ls-remote and fetch do not\nhave to know or care about push-url; they do not even have to know\nthere exists a thing called \"git push\" ;-)\n\nWouldn't \"git push -v -n\" or something suit your needs already?\n"},{"id":"267212","messageId":"20150731185619.GA24622@megas.kitware.com","threadId":"39982","inReplyTo":"xmqqfv445fxv.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] add ls-remote --get-push-url option","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-07-31T18:56:19Z","receivedAt":"2015-07-31T18:56:19Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"On Fri, Jul 31, 2015 at 11:40:12 -0700, Junio C Hamano wrote:\n> Probably get-url makes (some) sense because ls-remote is a \"fetch\n> that does not actually fetch anything\".  But \"get-push-url\" to\n> ls-remote makes _no_ sense whatsoever.  ls-remote and fetch do not\n> have to know or care about push-url; they do not even have to know\n> there exists a thing called \"git push\" ;-)\n> \n> Wouldn't \"git push -v -n\" or something suit your needs already?\n\nWith some sed, yes, but then so would `git remote show` just as useful\ntoo (and in that case, \"why does --get-url exist either?\" comes to\nmind).\n\nOur use case is that we have some scripts which setup the project with\nthe right remotes and such. To do this, we detect if your remotes are\nset up properly already and not ask if things are OK already. This is\ncurrently done with git config --get remote.$x.pushurl, but\n`pushInsteadOf` is not expanded and causes false positives.\n\nWhere would a utility to have git expand its `pushInsteadOf` aliases\nmake more sense? Being right beside `insteadOf` expansion made sense to\nme (certainly more than some locations for certain flags and actions,\nbut that boat sailed long ago :) ).\n\n--Ben\n"},{"id":"267215","messageId":"xmqq4mkk5ex5.fsf@gitster.dls.corp.google.com","threadId":"39982","inReplyTo":"20150731185619.GA24622@megas.kitware.com","subject":"Re: [PATCH] add ls-remote --get-push-url option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-31T19:02:14Z","receivedAt":"2015-07-31T19:02:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Boeckel <mathstuf@gmail.com> writes:\n\n> With some sed, yes, but then so would `git remote show` just as useful\n> too (and in that case, \"why does --get-url exist either?\" comes to\n> mind).\n\nEither carelessness let it slip in, or it came before 'git remote show'.\n"},{"id":"267216","messageId":"20150731190415.GA23674@megas.kitware.com","threadId":"39982","inReplyTo":"xmqq4mkk5ex5.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] add ls-remote --get-push-url option","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-07-31T19:04:15Z","receivedAt":"2015-07-31T19:04:15Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"On Fri, Jul 31, 2015 at 12:02:14 -0700, Junio C Hamano wrote:\n> Ben Boeckel <mathstuf@gmail.com> writes:\n> \n> > With some sed, yes, but then so would `git remote show` just as useful\n> > too (and in that case, \"why does --get-url exist either?\" comes to\n> > mind).\n> \n> Either carelessness let it slip in, or it came before 'git remote show'.\n\nWould adding `git remote show --url $remote` and `git remote show\n--push-url $remote` be acceptable?\n\n--Ben\n"},{"id":"267217","messageId":"xmqqzj2c3zoh.fsf@gitster.dls.corp.google.com","threadId":"39982","inReplyTo":"20150731190415.GA23674@megas.kitware.com","subject":"Re: [PATCH] add ls-remote --get-push-url option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-31T19:16:46Z","receivedAt":"2015-07-31T19:16:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Boeckel <mathstuf@gmail.com> writes:\n\n> On Fri, Jul 31, 2015 at 12:02:14 -0700, Junio C Hamano wrote:\n>> Ben Boeckel <mathstuf@gmail.com> writes:\n>> \n>> > With some sed, yes, but then so would `git remote show` just as useful\n>> > too (and in that case, \"why does --get-url exist either?\" comes to\n>> > mind).\n>> \n>> Either carelessness let it slip in, or it came before 'git remote show'.\n>\n> Would adding `git remote show --url $remote` and `git remote show\n> --push-url $remote` be acceptable?\n\nIt is not just acceptable; I think \"git remote\" is a much better\nplace to have something like that.\n\nOr even \"git remote get url [$there]\", \"git remote get push-url [$there]\".\n\nOr to mirror the existing \"ls-remote --get-url [$there]\", which directly asks\n\"where does this request go if I run it without '--get-url' option?\":\n\n    $ git push --get-url [$there [$refspec...]]\n    $ git push --get-refspec [$there [$refspec...]]\n\nmight be a better option.  The logic in \"push\" takes the current\nbranch and configurations like branch.*.remote and push.default into\naccount, so it is likely that you will get the exact information\nwithout too much code.\n\nI am not opposed to having a scriptable interface to obtain these\npieces of information.  I was only objecting to teach ls-remote\nanything about push, which ls-remote does not have anything to do\nwith.\n"},{"id":"267224","messageId":"20150731205142.GB6556@megas.kitware.com","threadId":"39982","inReplyTo":"xmqqzj2c3zoh.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] add ls-remote --get-push-url option","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-07-31T20:51:42Z","receivedAt":"2015-07-31T20:51:42Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"On Fri, Jul 31, 2015 at 12:16:46 -0700, Junio C Hamano wrote:\n> Or even \"git remote get url [$there]\", \"git remote get push-url [$there]\".\n\nLooking at `git remote`'s existing subcommands, consistency there would\nbe something like:\n\n    git remote get-url $there\n    git remote get-url --push $there\n\nThe new call could also show *all* remotes which will be pushed to, not\njust the first. Looking at the structure, it also has fields for\nmultiple fetch urls. I would assume git would fetch the union of refs;\nnot sure about conflicts and such.\n\n> Or to mirror the existing \"ls-remote --get-url [$there]\", which directly asks\n> \"where does this request go if I run it without '--get-url' option?\":\n> \n>     $ git push --get-url [$there [$refspec...]]\n>     $ git push --get-refspec [$there [$refspec...]]\n> \n> might be a better option.  The logic in \"push\" takes the current\n> branch and configurations like branch.*.remote and push.default into\n> account, so it is likely that you will get the exact information\n> without too much code.\n\nThis is a little weird to me. `git push` is porcelain; `git ls-remote`\nfeels more like plumbing (command-list.txt seems to agree). Maybe it is\nalso useful since it takes these other configuration values into\naccount. But maybe pushing has enough extra factors? Might it make sense\nin addition to a `git remote get-url`?\n\n> I am not opposed to having a scriptable interface to obtain these\n> pieces of information.  I was only objecting to teach ls-remote\n> anything about push, which ls-remote does not have anything to do\n> with.\n\nOK. Thanks.\n\n--Ben\n"},{"id":"267344","messageId":"1438635614-11174-1-git-send-email-mathstuf@gmail.com","threadId":"39982","inReplyTo":"1438364321-14646-1-git-send-email-mathstuf@gmail.com","subject":"[PATCH v2] add git-url subcommand","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-08-03T21:00:13Z","receivedAt":"2015-08-03T21:00:13Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"Implements a get-url subcommand to git-remote which allows for querying the\nURLs for a remote while expanding insteadOf and pushInsteadOf.\n\n--Ben\n\nBen Boeckel (1):\n  remote: add get-url subcommand\n\n Documentation/git-remote.txt | 10 ++++++++\n builtin/remote.c             | 55 ++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 65 insertions(+)\n\n-- \n2.1.0\n"},{"id":"267345","messageId":"1438635614-11174-2-git-send-email-mathstuf@gmail.com","threadId":"39982","inReplyTo":"1438635614-11174-1-git-send-email-mathstuf@gmail.com","subject":"[PATCH v2] remote: add get-url subcommand","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-08-03T21:00:14Z","receivedAt":"2015-08-03T21:00:14Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"Expanding `insteadOf` is a part of ls-remote --url and there is no way\nto expand `pushInsteadOf` as well. Add a get-url subcommand to be able\nto query both as well as a way to get all configured urls.\n\nSigned-off-by: Ben Boeckel <mathstuf@gmail.com>\n---\n Documentation/git-remote.txt | 10 ++++++++\n builtin/remote.c             | 55 ++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 65 insertions(+)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 4c6d6de..c47b634 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -15,6 +15,7 @@ SYNOPSIS\n 'git remote remove' <name>\n 'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>)\n 'git remote set-branches' [--add] <name> <branch>...\n+'git remote get-url' [--push] [--all] <name>\n 'git remote set-url' [--push] <name> <newurl> [<oldurl>]\n 'git remote set-url --add' [--push] <name> <newurl>\n 'git remote set-url --delete' [--push] <name> <url>\n@@ -131,6 +132,15 @@ The named branches will be interpreted as if specified with the\n With `--add`, instead of replacing the list of currently tracked\n branches, adds to that list.\n \n+'get-url'::\n+\n+Retrieves the URLs for a remote. Configurations for `insteadOf` and\n+`pushInsteadOf` are expanded here. By default, only the first URL is listed.\n++\n+With '--push', push URLs are queried instead of fetch URLs.\n++\n+With '--all', all URLs for the remote will be listed.\n+\n 'set-url'::\n \n Changes URLs for the remote. Sets first URL for remote <name> that matches\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex f4a6ec9..9278a83 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -18,6 +18,7 @@ static const char * const builtin_remote_usage[] = {\n \tN_(\"git remote prune [-n | --dry-run] <name>\"),\n \tN_(\"git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]\"),\n \tN_(\"git remote set-branches [--add] <name> <branch>...\"),\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n \tN_(\"git remote set-url --delete <name> <url>\"),\n@@ -65,6 +66,11 @@ static const char * const builtin_remote_update_usage[] = {\n \tNULL\n };\n \n+static const char * const builtin_remote_geturl_usage[] = {\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n+\tNULL\n+};\n+\n static const char * const builtin_remote_seturl_usage[] = {\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n@@ -1497,6 +1503,53 @@ static int set_branches(int argc, const char **argv)\n \treturn set_remote_branches(argv[0], argv + 1, add_mode);\n }\n \n+static int get_url(int argc, const char **argv)\n+{\n+\tint i, push_mode = 0, all_mode = 0;\n+\tconst char *remotename = NULL;\n+\tstruct remote *remote;\n+\tconst char **url;\n+\tint url_nr;\n+\tstruct option options[] = {\n+\t\tOPT_BOOL('\\0', \"push\", &push_mode,\n+\t\t\t N_(\"query push URLs\")),\n+\t\tOPT_BOOL('\\0', \"all\", &all_mode,\n+\t\t\t N_(\"return all URLs\")),\n+\t\tOPT_END()\n+\t};\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_geturl_usage,\n+\t\t\t     PARSE_OPT_KEEP_ARGV0);\n+\n+\tif (argc < 1 || argc > 2)\n+\t\tusage_with_options(builtin_remote_geturl_usage, options);\n+\n+\tremotename = argv[1];\n+\n+\tif (!remote_is_configured(remotename))\n+\t\tdie(_(\"No such remote '%s'\"), remotename);\n+\tremote = remote_get(remotename);\n+\n+\tif (push_mode) {\n+\t\turl = remote->pushurl;\n+\t\turl_nr = remote->pushurl_nr;\n+\t} else {\n+\t\turl = remote->url;\n+\t\turl_nr = remote->url_nr;\n+\t}\n+\n+\tif (!url_nr)\n+\t\tdie(_(\"no URLs configured for remote '%s'\"), remotename);\n+\n+\tif (all_mode) {\n+\t\tfor (i = 0; i < url_nr; i++)\n+\t\t\tprintf_ln(\"%s\", url[i]);\n+\t} else {\n+\t\tprintf_ln(\"%s\", *url);\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int set_url(int argc, const char **argv)\n {\n \tint i, push_mode = 0, add_mode = 0, delete_mode = 0;\n@@ -1606,6 +1659,8 @@ int cmd_remote(int argc, const char **argv, const char *prefix)\n \t\tresult = set_head(argc, argv);\n \telse if (!strcmp(argv[0], \"set-branches\"))\n \t\tresult = set_branches(argc, argv);\n+\telse if (!strcmp(argv[0], \"get-url\"))\n+\t\tresult = get_url(argc, argv);\n \telse if (!strcmp(argv[0], \"set-url\"))\n \t\tresult = set_url(argc, argv);\n \telse if (!strcmp(argv[0], \"show\"))\n-- \n2.1.0\n"},{"id":"267374","messageId":"CAPig+cQO_jXZmJG=EccwQ408TiAk7_BiQF1UKA31phXF7CXy6w@mail.gmail.com","threadId":"39982","inReplyTo":"1438635614-11174-2-git-send-email-mathstuf@gmail.com","subject":"Re: [PATCH v2] remote: add get-url subcommand","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-08-03T23:38:15Z","receivedAt":"2015-08-03T23:38:15Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Aug 3, 2015 at 5:00 PM, Ben Boeckel <mathstuf@gmail.com> wrote:\n> Expanding `insteadOf` is a part of ls-remote --url and there is no way\n> to expand `pushInsteadOf` as well. Add a get-url subcommand to be able\n> to query both as well as a way to get all configured urls.\n>\n> Signed-off-by: Ben Boeckel <mathstuf@gmail.com>\n> ---\n> diff --git a/builtin/remote.c b/builtin/remote.c\n> index f4a6ec9..9278a83 100644\n> --- a/builtin/remote.c\n> +++ b/builtin/remote.c\n> @@ -1497,6 +1503,53 @@ static int set_branches(int argc, const char **argv)\n> +static int get_url(int argc, const char **argv)\n> +{\n> +       int i, push_mode = 0, all_mode = 0;\n> +       const char *remotename = NULL;\n> +       struct remote *remote;\n> +       const char **url;\n> +       int url_nr;\n> +       struct option options[] = {\n> +               OPT_BOOL('\\0', \"push\", &push_mode,\n> +                        N_(\"query push URLs\")),\n\nA bit more explanatory:\n\n    \"query push URLs rather than fetch URLs\"\n\n> +               OPT_BOOL('\\0', \"all\", &all_mode,\n> +                        N_(\"return all URLs\")),\n> +               OPT_END()\n> +       };\n> +       argc = parse_options(argc, argv, NULL, options, builtin_remote_geturl_usage,\n> +                            PARSE_OPT_KEEP_ARGV0);\n\nWhat is the reason for PARSE_OPT_KEEP_ARGV0 in this case?\n\n> +       if (argc < 1 || argc > 2)\n> +               usage_with_options(builtin_remote_geturl_usage, options);\n\nSo,  'argc' must be 1 or 2, which in 'argv' terms is argv[0] and argv[1]).\n\n> +       remotename = argv[1];\n\nBut here, argv[1] is accessed unconditionally, even though 'argc' may\nhave been 1, thus out of bounds.\n\n> +       if (!remote_is_configured(remotename))\n> +               die(_(\"No such remote '%s'\"), remotename);\n> +       remote = remote_get(remotename);\n> +\n> +       if (push_mode) {\n> +               url = remote->pushurl;\n> +               url_nr = remote->pushurl_nr;\n> +       } else {\n> +               url = remote->url;\n> +               url_nr = remote->url_nr;\n> +       }\n> +\n> +       if (!url_nr)\n> +               die(_(\"no URLs configured for remote '%s'\"), remotename);\n> +\n> +       if (all_mode) {\n> +               for (i = 0; i < url_nr; i++)\n> +                       printf_ln(\"%s\", url[i]);\n> +       } else {\n> +               printf_ln(\"%s\", *url);\n> +       }\n> +\n> +       return 0;\n> +}\n"},{"id":"267377","messageId":"20150804001631.GA10416@megas.kitware.com","threadId":"39982","inReplyTo":"CAPig+cQO_jXZmJG=EccwQ408TiAk7_BiQF1UKA31phXF7CXy6w@mail.gmail.com","subject":"Re: [PATCH v2] remote: add get-url subcommand","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-08-04T00:16:31Z","receivedAt":"2015-08-04T00:16:31Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"On Mon, Aug 03, 2015 at 19:38:15 -0400, Eric Sunshine wrote:\n> On Mon, Aug 3, 2015 at 5:00 PM, Ben Boeckel <mathstuf@gmail.com> wrote:\n> > +               OPT_BOOL('\\0', \"push\", &push_mode,\n> > +                        N_(\"query push URLs\")),\n> \n> A bit more explanatory:\n> \n>     \"query push URLs rather than fetch URLs\"\n\nFixed.\n\n> > +               OPT_BOOL('\\0', \"all\", &all_mode,\n> > +                        N_(\"return all URLs\")),\n> > +               OPT_END()\n> > +       };\n> > +       argc = parse_options(argc, argv, NULL, options, builtin_remote_geturl_usage,\n> > +                            PARSE_OPT_KEEP_ARGV0);\n> \n> What is the reason for PARSE_OPT_KEEP_ARGV0 in this case?\n\nCopied from get-url; I presume for more natural argv[] usage within the\nfunction.\n\n> > +       if (argc < 1 || argc > 2)\n> > +               usage_with_options(builtin_remote_geturl_usage, options);\n> \n> So,  'argc' must be 1 or 2, which in 'argv' terms is argv[0] and argv[1]).\n\n…\n\n> > +       remotename = argv[1];\n> \n> But here, argv[1] is accessed unconditionally, even though 'argc' may\n> have been 1, thus out of bounds.\n\nYep, should be (argc < 2 || argc > 2) (or 1 if PARSE_OPT_KEEP_ARGV0 is\nremoved). Off-by-one when converting from get-url.\n\nI'll reroll tomorrow morning in case there are more comments until then\n(particularly about PARSE_OPT_KEEP_ARGV0).\n\nThanks,\n\n--Ben\n"},{"id":"267378","messageId":"CAPig+cSNNtNP93U6jy3X424FV3SRvoLr3PZaYe3m+auOM+gWcA@mail.gmail.com","threadId":"39982","inReplyTo":"20150804001631.GA10416@megas.kitware.com","subject":"Re: [PATCH v2] remote: add get-url subcommand","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-08-04T00:45:11Z","receivedAt":"2015-08-04T00:45:11Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Aug 3, 2015 at 8:16 PM, Ben Boeckel <mathstuf@gmail.com> wrote:\n> On Mon, Aug 03, 2015 at 19:38:15 -0400, Eric Sunshine wrote:\n>> On Mon, Aug 3, 2015 at 5:00 PM, Ben Boeckel <mathstuf@gmail.com> wrote:\n>> > +       argc = parse_options(argc, argv, NULL, options, builtin_remote_geturl_usage,\n>> > +                            PARSE_OPT_KEEP_ARGV0);\n>>\n>> What is the reason for PARSE_OPT_KEEP_ARGV0 in this case?\n>\n> Copied from get-url; I presume for more natural argv[] usage within the\n> function.\n>\n>> > +       if (argc < 1 || argc > 2)\n>> > +               usage_with_options(builtin_remote_geturl_usage, options);\n>>\n>> So,  'argc' must be 1 or 2, which in 'argv' terms is argv[0] and argv[1]).\n>>\n>> > +       remotename = argv[1];\n>>\n>> But here, argv[1] is accessed unconditionally, even though 'argc' may\n>> have been 1, thus out of bounds.\n>\n> Yep, should be (argc < 2 || argc > 2) (or 1 if PARSE_OPT_KEEP_ARGV0 is\n> removed). Off-by-one when converting from get-url.\n\nOr, expressed more naturally:\n\n    if (argc != 1)\n        usage_with_options(...);\n\nassuming the unnecessary PARSE_OPT_KEEP_ARGV0 is dropped.\n\n> I'll reroll tomorrow morning in case there are more comments until then\n> (particularly about PARSE_OPT_KEEP_ARGV0).\n\nThis new code doesn't take advantage of it, and it's very rarely used\nin Git itself, thus its use here is a potential source of confusion,\nso it's probably best to drop it. (The same could be said for\nset_url(), but that's a separate topic.)\n"},{"id":"267471","messageId":"1438700198-4942-1-git-send-email-mathstuf@gmail.com","threadId":"39982","inReplyTo":"1438364321-14646-1-git-send-email-mathstuf@gmail.com","subject":"[PATCH v3] remote: add get-url subcommand","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-08-04T14:56:38Z","receivedAt":"2015-08-04T14:56:38Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"Expanding `insteadOf` is a part of ls-remote --url and there is no way\nto expand `pushInsteadOf` as well. Add a get-url subcommand to be able\nto query both as well as a way to get all configured urls.\n\nSigned-off-by: Ben Boeckel <mathstuf@gmail.com>\n---\n Documentation/git-remote.txt | 10 ++++++++\n builtin/remote.c             | 54 ++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 64 insertions(+)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 4c6d6de..3c9bf45 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -15,6 +15,7 @@ SYNOPSIS\n 'git remote remove' <name>\n 'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>)\n 'git remote set-branches' [--add] <name> <branch>...\n+'git remote get-url' [--push] [--all] <name>\n 'git remote set-url' [--push] <name> <newurl> [<oldurl>]\n 'git remote set-url --add' [--push] <name> <newurl>\n 'git remote set-url --delete' [--push] <name> <url>\n@@ -131,6 +132,15 @@ The named branches will be interpreted as if specified with the\n With `--add`, instead of replacing the list of currently tracked\n branches, adds to that list.\n \n+'get-url'::\n+\n+Retrieves the URLs for a remote. Configurations for `insteadOf` and\n+`pushInsteadOf` are expanded here. By default, only the first URL is listed.\n++\n+With '--push', push URLs are queried rather than fetch URLs.\n++\n+With '--all', all URLs for the remote will be listed.\n+\n 'set-url'::\n \n Changes URLs for the remote. Sets first URL for remote <name> that matches\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex f4a6ec9..904869a 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -18,6 +18,7 @@ static const char * const builtin_remote_usage[] = {\n \tN_(\"git remote prune [-n | --dry-run] <name>\"),\n \tN_(\"git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]\"),\n \tN_(\"git remote set-branches [--add] <name> <branch>...\"),\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n \tN_(\"git remote set-url --delete <name> <url>\"),\n@@ -65,6 +66,11 @@ static const char * const builtin_remote_update_usage[] = {\n \tNULL\n };\n \n+static const char * const builtin_remote_geturl_usage[] = {\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n+\tNULL\n+};\n+\n static const char * const builtin_remote_seturl_usage[] = {\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n@@ -1497,6 +1503,52 @@ static int set_branches(int argc, const char **argv)\n \treturn set_remote_branches(argv[0], argv + 1, add_mode);\n }\n \n+static int get_url(int argc, const char **argv)\n+{\n+\tint i, push_mode = 0, all_mode = 0;\n+\tconst char *remotename = NULL;\n+\tstruct remote *remote;\n+\tconst char **url;\n+\tint url_nr;\n+\tstruct option options[] = {\n+\t\tOPT_BOOL('\\0', \"push\", &push_mode,\n+\t\t\t N_(\"query push URLs rather than fetch URLs\")),\n+\t\tOPT_BOOL('\\0', \"all\", &all_mode,\n+\t\t\t N_(\"return all URLs\")),\n+\t\tOPT_END()\n+\t};\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_geturl_usage, 0);\n+\n+\tif (argc != 1)\n+\t\tusage_with_options(builtin_remote_geturl_usage, options);\n+\n+\tremotename = argv[0];\n+\n+\tif (!remote_is_configured(remotename))\n+\t\tdie(_(\"No such remote '%s'\"), remotename);\n+\tremote = remote_get(remotename);\n+\n+\tif (push_mode) {\n+\t\turl = remote->pushurl;\n+\t\turl_nr = remote->pushurl_nr;\n+\t} else {\n+\t\turl = remote->url;\n+\t\turl_nr = remote->url_nr;\n+\t}\n+\n+\tif (!url_nr)\n+\t\tdie(_(\"no URLs configured for remote '%s'\"), remotename);\n+\n+\tif (all_mode) {\n+\t\tfor (i = 0; i < url_nr; i++)\n+\t\t\tprintf_ln(\"%s\", url[i]);\n+\t} else {\n+\t\tprintf_ln(\"%s\", *url);\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int set_url(int argc, const char **argv)\n {\n \tint i, push_mode = 0, add_mode = 0, delete_mode = 0;\n@@ -1606,6 +1658,8 @@ int cmd_remote(int argc, const char **argv, const char *prefix)\n \t\tresult = set_head(argc, argv);\n \telse if (!strcmp(argv[0], \"set-branches\"))\n \t\tresult = set_branches(argc, argv);\n+\telse if (!strcmp(argv[0], \"get-url\"))\n+\t\tresult = get_url(argc, argv);\n \telse if (!strcmp(argv[0], \"set-url\"))\n \t\tresult = set_url(argc, argv);\n \telse if (!strcmp(argv[0], \"show\"))\n-- \n2.1.0\n"},{"id":"267537","messageId":"xmqqio8t325x.fsf@gitster.dls.corp.google.com","threadId":"39982","inReplyTo":"1438700198-4942-1-git-send-email-mathstuf@gmail.com","subject":"Re: [PATCH v3] remote: add get-url subcommand","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-08-05T20:34:18Z","receivedAt":"2015-08-05T20:34:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Boeckel <mathstuf@gmail.com> writes:\n\n> Expanding `insteadOf` is a part of ls-remote --url and there is no way\n> to expand `pushInsteadOf` as well. Add a get-url subcommand to be able\n> to query both as well as a way to get all configured urls.\n>\n> Signed-off-by: Ben Boeckel <mathstuf@gmail.com>\n> ---\n>  Documentation/git-remote.txt | 10 ++++++++\n>  builtin/remote.c             | 54 ++++++++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 64 insertions(+)\n\nChanges to these two files look reasonable.\n\nDon't you want to protect this feature from future breakage by\nothers by adding a couple of tests, though, to t/t5505?\n\nThanks.\n"},{"id":"267545","messageId":"20150805213358.GA2592@megas.kitware.com","threadId":"39982","inReplyTo":"xmqqio8t325x.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v3] remote: add get-url subcommand","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-08-05T21:33:58Z","receivedAt":"2015-08-05T21:33:58Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"On Wed, Aug 05, 2015 at 13:34:18 -0700, Junio C Hamano wrote:\n> Changes to these two files look reasonable.\n> \n> Don't you want to protect this feature from future breakage by\n> others by adding a couple of tests, though, to t/t5505?\n\nThanks, I've done so locally. It actually brings up this case:\n\n    $ git remote add someremote foo\n    $ git remote get-url --push someremote\n    fatal: no URLs configured for remote 'someremote'\n\nIs it better to use:\n\n    remote = remote_get(remotename);\n    remote->pushurl;\n\n    if (remote->pushurl_nr)\n        remote->pushurl;\n    else\n        remote->url;\n\nor:\n\n    remote = pushremote_get(remotename);\n    remote->pushurl;\n\n? What is the actual difference between the two?\n\nThanks,\n\n--Ben\n"},{"id":"267547","messageId":"xmqq1tfh2z5g.fsf@gitster.dls.corp.google.com","threadId":"39982","inReplyTo":"20150805213358.GA2592@megas.kitware.com","subject":"Re: [PATCH v3] remote: add get-url subcommand","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-08-05T21:39:23Z","receivedAt":"2015-08-05T21:39:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Boeckel <mathstuf@gmail.com> writes:\n\n> On Wed, Aug 05, 2015 at 13:34:18 -0700, Junio C Hamano wrote:\n>> Changes to these two files look reasonable.\n>> \n>> Don't you want to protect this feature from future breakage by\n>> others by adding a couple of tests, though, to t/t5505?\n>\n> Thanks, I've done so locally. It actually brings up this case:\n>\n>     $ git remote add someremote foo\n>     $ git remote get-url --push someremote\n>     fatal: no URLs configured for remote 'someremote'\n>\n> Is it better to use:\n>\n>     remote = remote_get(remotename);\n>     remote->pushurl;\n>\n>     if (remote->pushurl_nr)\n>         remote->pushurl;\n>     else\n>         remote->url;\n>\n> or:\n>\n>     remote = pushremote_get(remotename);\n>     remote->pushurl;\n>\n> ? What is the actual difference between the two?\n\nYou tell me ;-)\n\nThe default remote based on the current branch is computed\ndifferently based on the direction of the transfer, I think.\n\n        struct remote *remote_get(const char *name)\n        {\n                return remote_get_1(name, remote_for_branch);\n        }\n\n        struct remote *pushremote_get(const char *name)\n        {\n                return remote_get_1(name, pushremote_for_branch);\n        }\n\nWhen you are not giving name explicitly, the second parameter to _1 \nfunction is used to determine the name.\n"},{"id":"269424","messageId":"1441377024-23832-1-git-send-email-mathstuf@gmail.com","threadId":"39982","inReplyTo":"1438364321-14646-1-git-send-email-mathstuf@gmail.com","subject":"[PATCH v4] remote: add get-url subcommand","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-09-04T14:30:24Z","receivedAt":"2015-09-04T14:30:24Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"Expanding `insteadOf` is a part of ls-remote --url and there is no way\nto expand `pushInsteadOf` as well. Add a get-url subcommand to be able\nto query both as well as a way to get all configured urls.\n\nSigned-off-by: Ben Boeckel <mathstuf@gmail.com>\n---\n Documentation/git-remote.txt | 10 ++++++++\n builtin/remote.c             | 58 ++++++++++++++++++++++++++++++++++++++++++++\n t/t5505-remote.sh            | 53 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 121 insertions(+)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 4c6d6de..3c9bf45 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -15,6 +15,7 @@ SYNOPSIS\n 'git remote remove' <name>\n 'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>)\n 'git remote set-branches' [--add] <name> <branch>...\n+'git remote get-url' [--push] [--all] <name>\n 'git remote set-url' [--push] <name> <newurl> [<oldurl>]\n 'git remote set-url --add' [--push] <name> <newurl>\n 'git remote set-url --delete' [--push] <name> <url>\n@@ -131,6 +132,15 @@ The named branches will be interpreted as if specified with the\n With `--add`, instead of replacing the list of currently tracked\n branches, adds to that list.\n \n+'get-url'::\n+\n+Retrieves the URLs for a remote. Configurations for `insteadOf` and\n+`pushInsteadOf` are expanded here. By default, only the first URL is listed.\n++\n+With '--push', push URLs are queried rather than fetch URLs.\n++\n+With '--all', all URLs for the remote will be listed.\n+\n 'set-url'::\n \n Changes URLs for the remote. Sets first URL for remote <name> that matches\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 181668d..192b9cb 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -18,6 +18,7 @@ static const char * const builtin_remote_usage[] = {\n \tN_(\"git remote prune [-n | --dry-run] <name>\"),\n \tN_(\"git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]\"),\n \tN_(\"git remote set-branches [--add] <name> <branch>...\"),\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n \tN_(\"git remote set-url --delete <name> <url>\"),\n@@ -65,6 +66,11 @@ static const char * const builtin_remote_update_usage[] = {\n \tNULL\n };\n \n+static const char * const builtin_remote_geturl_usage[] = {\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n+\tNULL\n+};\n+\n static const char * const builtin_remote_seturl_usage[] = {\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n@@ -1467,6 +1473,56 @@ static int set_branches(int argc, const char **argv)\n \treturn set_remote_branches(argv[0], argv + 1, add_mode);\n }\n \n+static int get_url(int argc, const char **argv)\n+{\n+\tint i, push_mode = 0, all_mode = 0;\n+\tconst char *remotename = NULL;\n+\tstruct remote *remote;\n+\tconst char **url;\n+\tint url_nr;\n+\tstruct option options[] = {\n+\t\tOPT_BOOL('\\0', \"push\", &push_mode,\n+\t\t\t N_(\"query push URLs rather than fetch URLs\")),\n+\t\tOPT_BOOL('\\0', \"all\", &all_mode,\n+\t\t\t N_(\"return all URLs\")),\n+\t\tOPT_END()\n+\t};\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_geturl_usage, 0);\n+\n+\tif (argc != 1)\n+\t\tusage_with_options(builtin_remote_geturl_usage, options);\n+\n+\tremotename = argv[0];\n+\n+\tif (!remote_is_configured(remotename))\n+\t\tdie(_(\"No such remote '%s'\"), remotename);\n+\tremote = remote_get(remotename);\n+\n+\turl_nr = 0;\n+\tif (push_mode) {\n+\t\turl = remote->pushurl;\n+\t\turl_nr = remote->pushurl_nr;\n+\t}\n+\n+\t/* Fall back to the fetch URL if no push URLs are set. */\n+\tif (!url_nr) {\n+\t\turl = remote->url;\n+\t\turl_nr = remote->url_nr;\n+\t}\n+\n+\tif (!url_nr)\n+\t\tdie(_(\"no URLs configured for remote '%s'\"), remotename);\n+\n+\tif (all_mode) {\n+\t\tfor (i = 0; i < url_nr; i++)\n+\t\t\tprintf_ln(\"%s\", url[i]);\n+\t} else {\n+\t\tprintf_ln(\"%s\", *url);\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int set_url(int argc, const char **argv)\n {\n \tint i, push_mode = 0, add_mode = 0, delete_mode = 0;\n@@ -1576,6 +1632,8 @@ int cmd_remote(int argc, const char **argv, const char *prefix)\n \t\tresult = set_head(argc, argv);\n \telse if (!strcmp(argv[0], \"set-branches\"))\n \t\tresult = set_branches(argc, argv);\n+\telse if (!strcmp(argv[0], \"get-url\"))\n+\t\tresult = get_url(argc, argv);\n \telse if (!strcmp(argv[0], \"set-url\"))\n \t\tresult = set_url(argc, argv);\n \telse if (!strcmp(argv[0], \"show\"))\ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex 7a8499c..2cfd3cb 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -919,6 +919,18 @@ test_expect_success 'new remote' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url on new remote' '\n+\techo foo >expect &&\n+\tgit remote get-url someremote >actual &&\n+\tcmp expect actual &&\n+\tgit remote get-url --all someremote >actual &&\n+\tcmp expect actual &&\n+\tgit remote get-url --push someremote >actual &&\n+\tcmp expect actual &&\n+\tgit remote get-url --push --all someremote >actual &&\n+\tcmp expect actual\n+'\n+\n test_expect_success 'remote set-url bar' '\n \tgit remote set-url someremote bar &&\n \techo bar >expect &&\n@@ -961,6 +973,24 @@ test_expect_success 'remote set-url --push zot' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url with different urls' '\n+\techo baz >expect &&\n+\techo \"YYY\" >>expect &&\n+\techo baz >>expect &&\n+\techo \"YYY\" >>expect &&\n+\techo zot >>expect &&\n+\techo \"YYY\" >>expect &&\n+\techo zot >>expect &&\n+\tgit remote get-url someremote >actual &&\n+\techo \"YYY\" >>actual &&\n+\tgit remote get-url --all someremote >>actual &&\n+\techo \"YYY\" >>actual &&\n+\tgit remote get-url --push someremote >>actual &&\n+\techo \"YYY\" >>actual &&\n+\tgit remote get-url --push --all someremote >>actual &&\n+\tcmp expect actual\n+'\n+\n test_expect_success 'remote set-url --push qux zot' '\n \tgit remote set-url --push someremote qux zot &&\n \techo qux >expect &&\n@@ -995,6 +1025,17 @@ test_expect_success 'remote set-url --push --add aaa' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url on multi push remote' '\n+\techo foo >expect &&\n+\techo \"YYY\" >>expect &&\n+\techo foo >>expect &&\n+\techo aaa >>expect &&\n+\tgit remote get-url --push someremote >actual &&\n+\techo \"YYY\" >>actual &&\n+\tgit remote get-url --push --all someremote >>actual &&\n+\tcmp expect actual\n+'\n+\n test_expect_success 'remote set-url --push bar aaa' '\n \tgit remote set-url --push someremote bar aaa &&\n \techo foo >expect &&\n@@ -1039,6 +1080,17 @@ test_expect_success 'remote set-url --add bbb' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url on multi fetch remote' '\n+\techo baz >expect &&\n+\techo \"YYY\" >>expect &&\n+\techo baz >>expect &&\n+\techo bbb >>expect &&\n+\tgit remote get-url someremote >actual &&\n+\techo \"YYY\" >>actual &&\n+\tgit remote get-url --all someremote >>actual &&\n+\tcmp expect actual\n+'\n+\n test_expect_success 'remote set-url --delete .*' '\n \ttest_must_fail git remote set-url --delete someremote .\\* &&\n \techo \"YYY\" >expect &&\n@@ -1108,6 +1160,7 @@ test_extra_arg rename origin newname\n test_extra_arg remove origin\n test_extra_arg set-head origin master\n # set-branches takes any number of args\n+test_extra_arg get-url origin newurl\n test_extra_arg set-url origin newurl oldurl\n # show takes any number of args\n # prune takes any number of args\n-- \n2.5.0.1.g397396c.dirty\n"},{"id":"269456","messageId":"xmqqwpw5erk5.fsf@gitster.mtv.corp.google.com","threadId":"39982","inReplyTo":"1441377024-23832-1-git-send-email-mathstuf@gmail.com","subject":"Re: [PATCH v4] remote: add get-url subcommand","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-09-04T22:40:58Z","receivedAt":"2015-09-04T22:40:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Boeckel <mathstuf@gmail.com> writes:\n\n> +\turl_nr = 0;\n> +\tif (push_mode) {\n> +\t\turl = remote->pushurl;\n> +\t\turl_nr = remote->pushurl_nr;\n> +\t}\n> +\n> +\t/* Fall back to the fetch URL if no push URLs are set. */\n> +\tif (!url_nr) {\n> +\t\turl = remote->url;\n> +\t\turl_nr = remote->url_nr;\n> +\t}\n\nWhile the code does the right thing, the comment and the logic\nlooked somewhat on the side of funny than cute.  url_nr would be\nzero when we are asking for fetch URL, and it would be zero also\nwhen we are asking for push URL but there is no push URL defined.\nSo this statement covers both cases, but \"Fall back to\" talks only\nabout the case where the user asked for push URL.\n\n> diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\n> index 7a8499c..2cfd3cb 100755\n> --- a/t/t5505-remote.sh\n> +++ b/t/t5505-remote.sh\n> @@ -919,6 +919,18 @@ test_expect_success 'new remote' '\n>  \tcmp expect actual\n>  '\n>  \n> +test_expect_success 'get-url on new remote' '\n> +\techo foo >expect &&\n> +\tgit remote get-url someremote >actual &&\n> +\tcmp expect actual &&\n> +\tgit remote get-url --all someremote >actual &&\n> +\tcmp expect actual &&\n> +\tgit remote get-url --push someremote >actual &&\n> +\tcmp expect actual &&\n> +\tgit remote get-url --push --all someremote >actual &&\n> +\tcmp expect actual\n> +'\n\nIn the pre-context of this hunk, I can see that you inherited this\nhabit from existing tests, but breakage can be made easier to see\nif you used test_cmp instead of cmp.\n\n> @@ -961,6 +973,24 @@ test_expect_success 'remote set-url --push zot' '\n>  \tcmp expect actual\n>  '\n>  \n> +test_expect_success 'get-url with different urls' '\n> +\techo baz >expect &&\n> +\techo \"YYY\" >>expect &&\n> +\techo baz >>expect &&\n> +\techo \"YYY\" >>expect &&\n> +\techo zot >>expect &&\n> +\techo \"YYY\" >>expect &&\n> +\techo zot >>expect &&\n> +\tgit remote get-url someremote >actual &&\n> +\techo \"YYY\" >>actual &&\n> +\tgit remote get-url --all someremote >>actual &&\n> +\techo \"YYY\" >>actual &&\n> +\tgit remote get-url --push someremote >>actual &&\n> +\techo \"YYY\" >>actual &&\n> +\tgit remote get-url --push --all someremote >>actual &&\n> +\tcmp expect actual\n> +'\n\nI am not sure what these YYY are about. Is this an attempt to make\nit easier to see which of the output from four logically separate\ntests are broken?\n\nI am wondering if something along this line might be easier to read\nand maintain:\n\n\tget_url_test () {\n\t\tcat >expect &&\n\t\ttest_expect_success \"get-url $*\" '\n\t                git remote get-url $* >actual &&\n\t                test_cmp expect actual\n\t\t'\n\t}\n\n\techo baz | get_url_test someremote\n\techo baz | get_url_test --all someremote\n\nThen later when you have more than one pushURL to someremote, you\nwould do something like:\n\n\tget_url_test --all --push someremote <<\\-EOF\n\tfoo\n        aaa\n        EOF\n\nThis comment applies to the remainder of this patch that has YYY\nsprinkled all over it.\n\nThanks.\n"},{"id":"270092","messageId":"1442368427-3311-1-git-send-email-mathstuf@gmail.com","threadId":"39982","inReplyTo":"1438364321-14646-1-git-send-email-mathstuf@gmail.com","subject":"[PATCH v5] remote: add get-url subcommand","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-09-16T01:53:47Z","receivedAt":"2015-09-16T01:53:47Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"Expanding `insteadOf` is a part of ls-remote --url and there is no way\nto expand `pushInsteadOf` as well. Add a get-url subcommand to be able\nto query both as well as a way to get all configured urls.\n\nSigned-off-by: Ben Boeckel <mathstuf@gmail.com>\n---\n Documentation/git-remote.txt | 10 ++++++++\n builtin/remote.c             | 59 ++++++++++++++++++++++++++++++++++++++++++++\n t/t5505-remote.sh            | 39 +++++++++++++++++++++++++++++\n 3 files changed, 108 insertions(+)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 4c6d6de..3c9bf45 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -15,6 +15,7 @@ SYNOPSIS\n 'git remote remove' <name>\n 'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>)\n 'git remote set-branches' [--add] <name> <branch>...\n+'git remote get-url' [--push] [--all] <name>\n 'git remote set-url' [--push] <name> <newurl> [<oldurl>]\n 'git remote set-url --add' [--push] <name> <newurl>\n 'git remote set-url --delete' [--push] <name> <url>\n@@ -131,6 +132,15 @@ The named branches will be interpreted as if specified with the\n With `--add`, instead of replacing the list of currently tracked\n branches, adds to that list.\n \n+'get-url'::\n+\n+Retrieves the URLs for a remote. Configurations for `insteadOf` and\n+`pushInsteadOf` are expanded here. By default, only the first URL is listed.\n++\n+With '--push', push URLs are queried rather than fetch URLs.\n++\n+With '--all', all URLs for the remote will be listed.\n+\n 'set-url'::\n \n Changes URLs for the remote. Sets first URL for remote <name> that matches\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 181668d..e4c3ea1 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -18,6 +18,7 @@ static const char * const builtin_remote_usage[] = {\n \tN_(\"git remote prune [-n | --dry-run] <name>\"),\n \tN_(\"git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]\"),\n \tN_(\"git remote set-branches [--add] <name> <branch>...\"),\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n \tN_(\"git remote set-url --delete <name> <url>\"),\n@@ -65,6 +66,11 @@ static const char * const builtin_remote_update_usage[] = {\n \tNULL\n };\n \n+static const char * const builtin_remote_geturl_usage[] = {\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n+\tNULL\n+};\n+\n static const char * const builtin_remote_seturl_usage[] = {\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n@@ -1467,6 +1473,57 @@ static int set_branches(int argc, const char **argv)\n \treturn set_remote_branches(argv[0], argv + 1, add_mode);\n }\n \n+static int get_url(int argc, const char **argv)\n+{\n+\tint i, push_mode = 0, all_mode = 0;\n+\tconst char *remotename = NULL;\n+\tstruct remote *remote;\n+\tconst char **url;\n+\tint url_nr;\n+\tstruct option options[] = {\n+\t\tOPT_BOOL('\\0', \"push\", &push_mode,\n+\t\t\t N_(\"query push URLs rather than fetch URLs\")),\n+\t\tOPT_BOOL('\\0', \"all\", &all_mode,\n+\t\t\t N_(\"return all URLs\")),\n+\t\tOPT_END()\n+\t};\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_geturl_usage, 0);\n+\n+\tif (argc != 1)\n+\t\tusage_with_options(builtin_remote_geturl_usage, options);\n+\n+\tremotename = argv[0];\n+\n+\tif (!remote_is_configured(remotename))\n+\t\tdie(_(\"No such remote '%s'\"), remotename);\n+\tremote = remote_get(remotename);\n+\n+\turl_nr = 0;\n+\tif (push_mode) {\n+\t\turl = remote->pushurl;\n+\t\turl_nr = remote->pushurl_nr;\n+\t}\n+\t/* else fetch mode */\n+\n+\t/* Use the fetch URL when no push URLs were found or requested. */\n+\tif (!url_nr) {\n+\t\turl = remote->url;\n+\t\turl_nr = remote->url_nr;\n+\t}\n+\n+\tif (!url_nr)\n+\t\tdie(_(\"no URLs configured for remote '%s'\"), remotename);\n+\n+\tif (all_mode) {\n+\t\tfor (i = 0; i < url_nr; i++)\n+\t\t\tprintf_ln(\"%s\", url[i]);\n+\t} else {\n+\t\tprintf_ln(\"%s\", *url);\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int set_url(int argc, const char **argv)\n {\n \tint i, push_mode = 0, add_mode = 0, delete_mode = 0;\n@@ -1576,6 +1633,8 @@ int cmd_remote(int argc, const char **argv, const char *prefix)\n \t\tresult = set_head(argc, argv);\n \telse if (!strcmp(argv[0], \"set-branches\"))\n \t\tresult = set_branches(argc, argv);\n+\telse if (!strcmp(argv[0], \"get-url\"))\n+\t\tresult = get_url(argc, argv);\n \telse if (!strcmp(argv[0], \"set-url\"))\n \t\tresult = set_url(argc, argv);\n \telse if (!strcmp(argv[0], \"show\"))\ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex 7a8499c..f03ba4c 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -919,6 +919,21 @@ test_expect_success 'new remote' '\n \tcmp expect actual\n '\n \n+get_url_test () {\n+\tcat >expect &&\n+\ttest_expect_success \"get-url $*\" \"\n+\t\tgit remote get-url $* >actual &&\n+\t\ttest_cmp expect actual\n+\t\"\n+}\n+\n+test_expect_success 'get-url on new remote' '\n+\techo foo | get_url_test someremote &&\n+\techo foo | get_url_test --all someremote &&\n+\techo foo | get_url_test --push someremote &&\n+\techo foo | get_url_test --push --all someremote\n+'\n+\n test_expect_success 'remote set-url bar' '\n \tgit remote set-url someremote bar &&\n \techo bar >expect &&\n@@ -961,6 +976,13 @@ test_expect_success 'remote set-url --push zot' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url with different urls' '\n+\techo baz | get_url_test someremote &&\n+\techo baz | get_url_test --all someremote &&\n+\techo zot | get_url_test --push someremote &&\n+\techo zot | get_url_test --push --all someremote\n+'\n+\n test_expect_success 'remote set-url --push qux zot' '\n \tgit remote set-url --push someremote qux zot &&\n \techo qux >expect &&\n@@ -995,6 +1017,14 @@ test_expect_success 'remote set-url --push --add aaa' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url on multi push remote' '\n+\techo foo | get_url_test --push someremote &&\n+\tget_url_test --push --all someremote <<-\\EOF\n+\tfoo\n+\taaa\n+\tEOF\n+'\n+\n test_expect_success 'remote set-url --push bar aaa' '\n \tgit remote set-url --push someremote bar aaa &&\n \techo foo >expect &&\n@@ -1039,6 +1069,14 @@ test_expect_success 'remote set-url --add bbb' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url on multi fetch remote' '\n+\techo baz | get_url_test someremote &&\n+\tget_url_test --all someremote <<-\\EOF\n+\tbaz\n+\tbbb\n+\tEOF\n+'\n+\n test_expect_success 'remote set-url --delete .*' '\n \ttest_must_fail git remote set-url --delete someremote .\\* &&\n \techo \"YYY\" >expect &&\n@@ -1108,6 +1146,7 @@ test_extra_arg rename origin newname\n test_extra_arg remove origin\n test_extra_arg set-head origin master\n # set-branches takes any number of args\n+test_extra_arg get-url origin newurl\n test_extra_arg set-url origin newurl oldurl\n # show takes any number of args\n # prune takes any number of args\n-- \n2.5.2\n"},{"id":"270179","messageId":"xmqqtwqukmet.fsf@gitster.mtv.corp.google.com","threadId":"39982","inReplyTo":"1442368427-3311-1-git-send-email-mathstuf@gmail.com","subject":"Re: [PATCH v5] remote: add get-url subcommand","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-09-16T22:51:54Z","receivedAt":"2015-09-16T22:51:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Boeckel <mathstuf@gmail.com> writes:\n\n> +get_url_test () {\n> +\tcat >expect &&\n> +\ttest_expect_success \"get-url $*\" \"\n> +\t\tgit remote get-url $* >actual &&\n> +\t\ttest_cmp expect actual\n> +\t\"\n> +}\n\nThis makes any use of get_url_test inside test_expect_success wrong,\nI suspect.  Try running the tests under prove.  I think it will\ncomplain that the test numbers do not match or something.\n\nMinimally, this would probably fix the breakage.\n\n t/t5505-remote.sh | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex f03ba4c..dfaf9d9 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -921,10 +921,8 @@ test_expect_success 'new remote' '\n \n get_url_test () {\n \tcat >expect &&\n-\ttest_expect_success \"get-url $*\" \"\n-\t\tgit remote get-url $* >actual &&\n-\t\ttest_cmp expect actual\n-\t\"\n+\tgit remote get-url \"$@\" >actual &&\n+\ttest_cmp expect actual\n }\n \n test_expect_success 'get-url on new remote' '\n"},{"id":"270186","messageId":"1442449156-11995-1-git-send-email-mathstuf@gmail.com","threadId":"39982","inReplyTo":"1438364321-14646-1-git-send-email-mathstuf@gmail.com","subject":"[PATCH v6] remote: add get-url subcommand","fromName":"Ben Boeckel","fromEmail":"mathstuf@gmail.com","sentAt":"2015-09-17T00:19:16Z","receivedAt":"2015-09-17T00:19:16Z","isPatch":true,"sender":{"key":"mathstuf@gmail.com","avatar":"https://avatars.githubusercontent.com/u/97253?v=4"},"body":"Expanding `insteadOf` is a part of ls-remote --url and there is no way\nto expand `pushInsteadOf` as well. Add a get-url subcommand to be able\nto query both as well as a way to get all configured urls.\n\nSigned-off-by: Ben Boeckel <mathstuf@gmail.com>\n---\n Documentation/git-remote.txt | 10 ++++++++\n builtin/remote.c             | 59 ++++++++++++++++++++++++++++++++++++++++++++\n t/t5505-remote.sh            | 37 +++++++++++++++++++++++++++\n 3 files changed, 106 insertions(+)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 4c6d6de..3c9bf45 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -15,6 +15,7 @@ SYNOPSIS\n 'git remote remove' <name>\n 'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>)\n 'git remote set-branches' [--add] <name> <branch>...\n+'git remote get-url' [--push] [--all] <name>\n 'git remote set-url' [--push] <name> <newurl> [<oldurl>]\n 'git remote set-url --add' [--push] <name> <newurl>\n 'git remote set-url --delete' [--push] <name> <url>\n@@ -131,6 +132,15 @@ The named branches will be interpreted as if specified with the\n With `--add`, instead of replacing the list of currently tracked\n branches, adds to that list.\n \n+'get-url'::\n+\n+Retrieves the URLs for a remote. Configurations for `insteadOf` and\n+`pushInsteadOf` are expanded here. By default, only the first URL is listed.\n++\n+With '--push', push URLs are queried rather than fetch URLs.\n++\n+With '--all', all URLs for the remote will be listed.\n+\n 'set-url'::\n \n Changes URLs for the remote. Sets first URL for remote <name> that matches\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 181668d..e4c3ea1 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -18,6 +18,7 @@ static const char * const builtin_remote_usage[] = {\n \tN_(\"git remote prune [-n | --dry-run] <name>\"),\n \tN_(\"git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]\"),\n \tN_(\"git remote set-branches [--add] <name> <branch>...\"),\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n \tN_(\"git remote set-url --delete <name> <url>\"),\n@@ -65,6 +66,11 @@ static const char * const builtin_remote_update_usage[] = {\n \tNULL\n };\n \n+static const char * const builtin_remote_geturl_usage[] = {\n+\tN_(\"git remote get-url [--push] [--all] <name>\"),\n+\tNULL\n+};\n+\n static const char * const builtin_remote_seturl_usage[] = {\n \tN_(\"git remote set-url [--push] <name> <newurl> [<oldurl>]\"),\n \tN_(\"git remote set-url --add <name> <newurl>\"),\n@@ -1467,6 +1473,57 @@ static int set_branches(int argc, const char **argv)\n \treturn set_remote_branches(argv[0], argv + 1, add_mode);\n }\n \n+static int get_url(int argc, const char **argv)\n+{\n+\tint i, push_mode = 0, all_mode = 0;\n+\tconst char *remotename = NULL;\n+\tstruct remote *remote;\n+\tconst char **url;\n+\tint url_nr;\n+\tstruct option options[] = {\n+\t\tOPT_BOOL('\\0', \"push\", &push_mode,\n+\t\t\t N_(\"query push URLs rather than fetch URLs\")),\n+\t\tOPT_BOOL('\\0', \"all\", &all_mode,\n+\t\t\t N_(\"return all URLs\")),\n+\t\tOPT_END()\n+\t};\n+\targc = parse_options(argc, argv, NULL, options, builtin_remote_geturl_usage, 0);\n+\n+\tif (argc != 1)\n+\t\tusage_with_options(builtin_remote_geturl_usage, options);\n+\n+\tremotename = argv[0];\n+\n+\tif (!remote_is_configured(remotename))\n+\t\tdie(_(\"No such remote '%s'\"), remotename);\n+\tremote = remote_get(remotename);\n+\n+\turl_nr = 0;\n+\tif (push_mode) {\n+\t\turl = remote->pushurl;\n+\t\turl_nr = remote->pushurl_nr;\n+\t}\n+\t/* else fetch mode */\n+\n+\t/* Use the fetch URL when no push URLs were found or requested. */\n+\tif (!url_nr) {\n+\t\turl = remote->url;\n+\t\turl_nr = remote->url_nr;\n+\t}\n+\n+\tif (!url_nr)\n+\t\tdie(_(\"no URLs configured for remote '%s'\"), remotename);\n+\n+\tif (all_mode) {\n+\t\tfor (i = 0; i < url_nr; i++)\n+\t\t\tprintf_ln(\"%s\", url[i]);\n+\t} else {\n+\t\tprintf_ln(\"%s\", *url);\n+\t}\n+\n+\treturn 0;\n+}\n+\n static int set_url(int argc, const char **argv)\n {\n \tint i, push_mode = 0, add_mode = 0, delete_mode = 0;\n@@ -1576,6 +1633,8 @@ int cmd_remote(int argc, const char **argv, const char *prefix)\n \t\tresult = set_head(argc, argv);\n \telse if (!strcmp(argv[0], \"set-branches\"))\n \t\tresult = set_branches(argc, argv);\n+\telse if (!strcmp(argv[0], \"get-url\"))\n+\t\tresult = get_url(argc, argv);\n \telse if (!strcmp(argv[0], \"set-url\"))\n \t\tresult = set_url(argc, argv);\n \telse if (!strcmp(argv[0], \"show\"))\ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex 7a8499c..9a55389 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -919,6 +919,19 @@ test_expect_success 'new remote' '\n \tcmp expect actual\n '\n \n+get_url_test () {\n+\tcat >expect &&\n+\tgit remote get-url $* >actual &&\n+\ttest_cmp expect actual\n+}\n+\n+test_expect_success 'get-url on new remote' '\n+\techo foo | get_url_test someremote &&\n+\techo foo | get_url_test --all someremote &&\n+\techo foo | get_url_test --push someremote &&\n+\techo foo | get_url_test --push --all someremote\n+'\n+\n test_expect_success 'remote set-url bar' '\n \tgit remote set-url someremote bar &&\n \techo bar >expect &&\n@@ -961,6 +974,13 @@ test_expect_success 'remote set-url --push zot' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url with different urls' '\n+\techo baz | get_url_test someremote &&\n+\techo baz | get_url_test --all someremote &&\n+\techo zot | get_url_test --push someremote &&\n+\techo zot | get_url_test --push --all someremote\n+'\n+\n test_expect_success 'remote set-url --push qux zot' '\n \tgit remote set-url --push someremote qux zot &&\n \techo qux >expect &&\n@@ -995,6 +1015,14 @@ test_expect_success 'remote set-url --push --add aaa' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url on multi push remote' '\n+\techo foo | get_url_test --push someremote &&\n+\tget_url_test --push --all someremote <<-\\EOF\n+\tfoo\n+\taaa\n+\tEOF\n+'\n+\n test_expect_success 'remote set-url --push bar aaa' '\n \tgit remote set-url --push someremote bar aaa &&\n \techo foo >expect &&\n@@ -1039,6 +1067,14 @@ test_expect_success 'remote set-url --add bbb' '\n \tcmp expect actual\n '\n \n+test_expect_success 'get-url on multi fetch remote' '\n+\techo baz | get_url_test someremote &&\n+\tget_url_test --all someremote <<-\\EOF\n+\tbaz\n+\tbbb\n+\tEOF\n+'\n+\n test_expect_success 'remote set-url --delete .*' '\n \ttest_must_fail git remote set-url --delete someremote .\\* &&\n \techo \"YYY\" >expect &&\n@@ -1108,6 +1144,7 @@ test_extra_arg rename origin newname\n test_extra_arg remove origin\n test_extra_arg set-head origin master\n # set-branches takes any number of args\n+test_extra_arg get-url origin newurl\n test_extra_arg set-url origin newurl oldurl\n # show takes any number of args\n # prune takes any number of args\n-- \n2.5.2\n"}]}