{"thread":{"id":"19762","subject":"[PATCH 1/5] Allow push and fetch urls to be different","startedAt":"2009-06-09T16:01:33Z","lastAt":"2009-06-14T05:54:36Z","messageCount":15,"participants":["Michael J Gruber","Junio C Hamano","Bert Wesarg"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"115912","messageId":"1244563298-15479-1-git-send-email-git@drmicha.warpmail.net","threadId":"19762","inReplyTo":null,"subject":"[PATCH 0/5] Allow push and fetch urls to be different","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-09T16:01:33Z","receivedAt":"2009-06-09T16:01:33Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"This series implements a new config setting remote.${remotename}.pushurl\nwhich allows the urls for fetch and push to be different. \n\nIn http://permalink.gmane.org/gmane.comp.version-control.git/120726 the\nfeature was suggested, and an initital WIP/RFC was discussed. The patch\n1/5 contains exactly that version amended with documentation.\n\nIf there is no pushurl then all values of remote.${remotename}.url are\nused for pushes just like before. Otherwise, all values of\nremote.${remotename}.pushurl are used for pushes. In any case, the\nfirst value of remote.${remotename}.url is used for fetches.\n\n1/5 implements the config setting, makes push obey it and documents it.\n2/5 adds tests for the new setting.\n3/5 updates the api doc.\n4/5 makes \"remote show ${remotename}\" show the new push URLs, and makes\nclear which ones are used for fetch and which ones for push.\n5/5 brings the output of \"remote -v\" more in line with the output of the\nabove (it was out of sync even before 4/5).\n\n1 through 3 apply on yesterday's next.\n\n4 through 5 require tomorrow's next ;) More specifically, 4 requires\n'builtin-remote: Make \"remote show\" display all urls' which I suggested\nfor applying to maint in \nhttp://permalink.gmane.org/gmane.comp.version-control.git/120924\nbecause I think the current output is incomplete.\nIf that patch is not considered for separate inclusion in maint or\nmaster I would suggest squashing it together with 4/5 of the above.\n\nMichael J Gruber (5):\n  Allow push and fetch urls to be different\n  t5516: Check pushurl config setting\n  technical/api-remote: Describe new struct remote member pushurl\n  builtin-remote: Show push urls as well\n  builtin-remote: Make \"remote -v\" display push urls\n"},{"id":"115911","messageId":"1244563298-15479-2-git-send-email-git@drmicha.warpmail.net","threadId":"19762","inReplyTo":"1244563298-15479-1-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 1/5] Allow push and fetch urls to be different","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-09T16:01:34Z","receivedAt":"2009-06-09T16:01:34Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"This introduces a config setting remote.$remotename.pushurl which is\nused for pushes only. If absent remote.$remotename.url is used for\npushes and fetches as before.\nThis is useful, for example, in order to do passwordless fetches\n(remote update) over the git transport but pushes over ssh.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n Documentation/config.txt       |    3 +++\n Documentation/urls-remotes.txt |    3 +++\n builtin-push.c                 |   17 +++++++++++++----\n remote.c                       |   14 ++++++++++++++\n remote.h                       |    4 ++++\n 5 files changed, 37 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 3a86d1f..2fecbe3 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1319,6 +1319,9 @@ remote.<name>.url::\n \tThe URL of a remote repository.  See linkgit:git-fetch[1] or\n \tlinkgit:git-push[1].\n \n+remote.<name>.pushurl::\n+\tThe push URL of a remote repository.  See linkgit:git-push[1].\n+\n remote.<name>.proxy::\n \tFor remotes that require curl (http, https and ftp), the URL to\n \tthe proxy to use for that remote.  Set to the empty string to\ndiff --git a/Documentation/urls-remotes.txt b/Documentation/urls-remotes.txt\nindex 41ec777..2a0e7b8 100644\n--- a/Documentation/urls-remotes.txt\n+++ b/Documentation/urls-remotes.txt\n@@ -27,10 +27,13 @@ config file would appear like this:\n ------------\n \t[remote \"<name>\"]\n \t\turl = <url>\n+\t\tpushurl = <pushurl>\n \t\tpush = <refspec>\n \t\tfetch = <refspec>\n ------------\n \n+The `<pushurl>` is used for pushes only. It is optional and defaults\n+to `<url>`.\n \n Named file in `$GIT_DIR/remotes`\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ndiff --git a/builtin-push.c b/builtin-push.c\nindex c869974..7be1239 100644\n--- a/builtin-push.c\n+++ b/builtin-push.c\n@@ -117,6 +117,8 @@ static int do_push(const char *repo, int flags)\n {\n \tint i, errs;\n \tstruct remote *remote = remote_get(repo);\n+\tconst char **url;\n+\tint url_nr;\n \n \tif (!remote) {\n \t\tif (repo)\n@@ -152,9 +154,16 @@ static int do_push(const char *repo, int flags)\n \t\t\tsetup_default_push_refspecs();\n \t}\n \terrs = 0;\n-\tfor (i = 0; i < remote->url_nr; i++) {\n+\tif (remote->pushurl_nr) {\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+\tfor (i = 0; i < url_nr; i++) {\n \t\tstruct transport *transport =\n-\t\t\ttransport_get(remote, remote->url[i]);\n+\t\t\ttransport_get(remote, url[i]);\n \t\tint err;\n \t\tif (receivepack)\n \t\t\ttransport_set_option(transport,\n@@ -163,14 +172,14 @@ static int do_push(const char *repo, int flags)\n \t\t\ttransport_set_option(transport, TRANS_OPT_THIN, \"yes\");\n \n \t\tif (flags & TRANSPORT_PUSH_VERBOSE)\n-\t\t\tfprintf(stderr, \"Pushing to %s\\n\", remote->url[i]);\n+\t\t\tfprintf(stderr, \"Pushing to %s\\n\", url[i]);\n \t\terr = transport_push(transport, refspec_nr, refspec, flags);\n \t\terr |= transport_disconnect(transport);\n \n \t\tif (!err)\n \t\t\tcontinue;\n \n-\t\terror(\"failed to push some refs to '%s'\", remote->url[i]);\n+\t\terror(\"failed to push some refs to '%s'\", url[i]);\n \t\terrs++;\n \t}\n \treturn !!errs;\ndiff --git a/remote.c b/remote.c\nindex 08a5964..9a0397e 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -106,6 +106,12 @@ static void add_url_alias(struct remote *remote, const char *url)\n \tadd_url(remote, alias_url(url));\n }\n \n+static void add_pushurl(struct remote *remote, const char *pushurl)\n+{\n+\tALLOC_GROW(remote->pushurl, remote->pushurl_nr + 1, remote->pushurl_alloc);\n+\tremote->pushurl[remote->pushurl_nr++] = pushurl;\n+}\n+\n static struct remote *make_remote(const char *name, int len)\n {\n \tstruct remote *ret;\n@@ -379,6 +385,11 @@ static int handle_config(const char *key, const char *value, void *cb)\n \t\tif (git_config_string(&v, key, value))\n \t\t\treturn -1;\n \t\tadd_url(remote, v);\n+\t} else if (!strcmp(subkey, \".pushurl\")) {\n+\t\tconst char *v;\n+\t\tif (git_config_string(&v, key, value))\n+\t\t\treturn -1;\n+\t\tadd_pushurl(remote, v);\n \t} else if (!strcmp(subkey, \".push\")) {\n \t\tconst char *v;\n \t\tif (git_config_string(&v, key, value))\n@@ -424,6 +435,9 @@ static void alias_all_urls(void)\n \t\tfor (j = 0; j < remotes[i]->url_nr; j++) {\n \t\t\tremotes[i]->url[j] = alias_url(remotes[i]->url[j]);\n \t\t}\n+\t\tfor (j = 0; j < remotes[i]->pushurl_nr; j++) {\n+\t\t\tremotes[i]->pushurl[j] = alias_url(remotes[i]->pushurl[j]);\n+\t\t}\n \t}\n }\n \ndiff --git a/remote.h b/remote.h\nindex 257a555..5db8420 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -15,6 +15,10 @@ struct remote {\n \tint url_nr;\n \tint url_alloc;\n \n+\tconst char **pushurl;\n+\tint pushurl_nr;\n+\tint pushurl_alloc;\n+\n \tconst char **push_refspec;\n \tstruct refspec *push;\n \tint push_refspec_nr;\n-- \n1.6.3.2.278.gb6431.dirty\n"},{"id":"115913","messageId":"1244563298-15479-3-git-send-email-git@drmicha.warpmail.net","threadId":"19762","inReplyTo":"1244563298-15479-2-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 2/5] t5516: Check pushurl config setting","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-09T16:01:35Z","receivedAt":"2009-06-09T16:01:35Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Check whether the new remote.${remotename}.pushurl setting is obeyed\nand whether it overrides remote.${remotename}.url.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n t/t5516-fetch-push.sh |   13 +++++++++++++\n 1 files changed, 13 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex 89649e7..2d2633f 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -419,6 +419,19 @@ test_expect_success 'push with config remote.*.push = HEAD' '\n git config --remove-section remote.there\n git config --remove-section branch.master\n \n+test_expect_success 'push with config remote.*.pushurl' '\n+\n+\tmk_test heads/master &&\n+\tgit checkout master &&\n+\tgit config remote.there.url test2repo &&\n+\tgit config remote.there.pushurl testrepo &&\n+\tgit push there &&\n+\tcheck_push_result $the_commit heads/master\n+'\n+\n+# clean up the cruft left with the previous one\n+git config --remove-section remote.there\n+\n test_expect_success 'push with dry-run' '\n \n \tmk_test heads/master &&\n-- \n1.6.3.2.278.gb6431.dirty\n"},{"id":"115914","messageId":"1244563298-15479-4-git-send-email-git@drmicha.warpmail.net","threadId":"19762","inReplyTo":"1244563298-15479-3-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 3/5] technical/api-remote: Describe new struct remote member pushurl","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-09T16:01:36Z","receivedAt":"2009-06-09T16:01:36Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"...and pushurl_nr\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n Documentation/technical/api-remote.txt |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/technical/api-remote.txt b/Documentation/technical/api-remote.txt\nindex 073b22b..c54b17d 100644\n--- a/Documentation/technical/api-remote.txt\n+++ b/Documentation/technical/api-remote.txt\n@@ -18,6 +18,10 @@ struct remote\n \n \tAn array of all of the url_nr URLs configured for the remote\n \n+`pushurl`::\n+\n+\tAn array of all of the pushurl_nr push URLs configured for the remote\n+\n `push`::\n \n \t An array of refspecs configured for pushing, with\n-- \n1.6.3.2.278.gb6431.dirty\n"},{"id":"115915","messageId":"1244563298-15479-5-git-send-email-git@drmicha.warpmail.net","threadId":"19762","inReplyTo":"1244563298-15479-4-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 4/5] builtin-remote: Show push urls as well","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-09T16:01:37Z","receivedAt":"2009-06-09T16:01:37Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Teach builtin remote to show push urls also when asked to\n\"show\" a specific remote.\n\nThis improves upon the standard display mode: multiple specified \"url\"s\nmean that the first one is for fetching, all are used for pushing. We\nmake this clearer now by displaying the first one prefixed with \"Fetch\nURL\", and all \"url\"s (or, if present, all \"pushurl\"s) prefixed with\n\"Push  URL\".\n\nAlso, adjust t5505 accordingly and make it test for the new output.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n builtin-remote.c  |   20 +++++++++++++++-----\n t/t5505-remote.sh |   10 +++++++---\n 2 files changed, 22 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex dfc0b9e..b350b18 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -999,15 +999,25 @@ static int show(int argc, const char **argv)\n \tinfo.list = &info_list;\n \tfor (; argc; argc--, argv++) {\n \t\tint i;\n+\t\tconst char **url;\n+\t\tint url_nr;\n \n \t\tget_remote_ref_states(*argv, &states, query_flag);\n \n \t\tprintf(\"* remote %s\\n\", *argv);\n-\t\tif (states.remote->url_nr) {\n-\t\t\tfor (i=0; i < states.remote->url_nr; i++)\n-\t\t\t\tprintf(\"  URL: %s\\n\", states.remote->url[i]);\n-\t\t} else\n-\t\t\tprintf(\"  URL: %s\\n\", \"(no URL)\");\n+\t\tprintf(\"  Fetch URL: %s\\n\", states.remote->url_nr > 0 ?\n+\t\t\tstates.remote->url[0] : \"(no URL)\");\n+\t\tif (states.remote->pushurl_nr) {\n+\t\t\turl = states.remote->pushurl;\n+\t\t\turl_nr = states.remote->pushurl_nr;\n+\t\t} else {\n+\t\t\turl = states.remote->url;\n+\t\t\turl_nr = states.remote->url_nr;\n+\t\t}\n+\t\tfor (i=0; i < url_nr; i++)\n+\t\t\tprintf(\"  Push  URL: %s\\n\", url[i]);\n+\t\tif (!i)\n+\t\t\tprintf(\"  Push  URL: %s\\n\", \"(no URL)\");\n \t\tif (no_query)\n \t\t\tprintf(\"  HEAD branch: (not queried)\\n\");\n \t\telse if (!states.heads.nr)\ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex e70246b..852ccb5 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -135,7 +135,8 @@ EOF\n \n cat > test/expect << EOF\n * remote origin\n-  URL: $(pwd)/one\n+  Fetch URL: $(pwd)/one\n+  Push  URL: $(pwd)/one\n   HEAD branch: master\n   Remote branches:\n     master new (next fetch will store in remotes/origin)\n@@ -151,7 +152,8 @@ cat > test/expect << EOF\n     master pushes to master   (local out of date)\n     master pushes to upstream (create)\n * remote two\n-  URL: ../two\n+  Fetch URL: ../two\n+  Push  URL: ../three\n   HEAD branch (remote HEAD is ambiguous, may be one of the following):\n     another\n     master\n@@ -173,6 +175,7 @@ test_expect_success 'show' '\n \t git branch --track rebase origin/master &&\n \t git branch -d -r origin/master &&\n \t git config --add remote.two.url ../two &&\n+\t git config --add remote.two.pushurl ../three &&\n \t git config branch.rebase.rebase true &&\n \t git config branch.octopus.merge \"topic-a topic-b topic-c\" &&\n \t (cd ../one &&\n@@ -191,7 +194,8 @@ test_expect_success 'show' '\n \n cat > test/expect << EOF\n * remote origin\n-  URL: $(pwd)/one\n+  Fetch URL: $(pwd)/one\n+  Push  URL: $(pwd)/one\n   HEAD branch: (not queried)\n   Remote branches: (status not queried)\n     master\n-- \n1.6.3.2.278.gb6431.dirty\n"},{"id":"115916","messageId":"1244563298-15479-6-git-send-email-git@drmicha.warpmail.net","threadId":"19762","inReplyTo":"1244563298-15479-5-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 5/5] builtin-remote: Make \"remote -v\" display push urls","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-09T16:01:38Z","receivedAt":"2009-06-09T16:01:38Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Currently, \"remote -v\" simply lists all urls so that one has to remember\nthat only the first one is used for fetches, and all are used for\npushes.\n\nChange this so that the role of an url is displayed in parentheses, and\nalso display push urls.\n\nExample with \"mjg\" having 1 url and 1 pushurl, \"origin\" having 3 urls,\nsb having 1 url:\n\nmjg     git://repo.or.cz/git/mjg.git (fetch)\nmjg     repoor:/srv/git/git/mjg.git (push)\norigin  git://repo.or.cz/git.git (fetch)\norigin  git://repo.or.cz/git.git (push)\norigin  git://git2.kernel.org/pub/scm/git/git.git (push)\norigin  git://repo.or.cz/alt-git.git (push)\nsb      git://repo.or.cz/git/sbeyer.git (fetch)\nsb      git://repo.or.cz/git/sbeyer.git (push)\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n builtin-remote.c |   27 +++++++++++++++++++++++----\n 1 files changed, 23 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex b350b18..80b2536 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -1276,14 +1276,31 @@ static int update(int argc, const char **argv)\n static int get_one_entry(struct remote *remote, void *priv)\n {\n \tstruct string_list *list = priv;\n+\tconst char **url;\n+\tint i, url_nr;\n+\tvoid **utilp;\n \n \tif (remote->url_nr > 0) {\n-\t\tint i;\n-\n-\t\tfor (i = 0; i < remote->url_nr; i++)\n-\t\t\tstring_list_append(remote->name, list)->util = (void *)remote->url[i];\n+\t\tutilp = &(string_list_append(remote->name, list)->util);\n+\t\t*utilp = malloc(strlen(remote->url[0])+strlen(\" (fetch)\")+1);\n+\t\tstrcpy((char *) *utilp, remote->url[0]);\n+\t\tstrcat((char *) *utilp, \" (fetch)\");\n \t} else\n \t\tstring_list_append(remote->name, list)->util = NULL;\n+\tif (remote->pushurl_nr) {\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+\tfor (i = 0; i < url_nr; i++)\n+\t{\n+\t\tutilp = &(string_list_append(remote->name, list)->util);\n+\t\t*utilp = malloc(strlen(url[i])+strlen(\" (push)\")+1);\n+\t\tstrcpy((char *) *utilp, url[i]);\n+\t\tstrcat((char *) *utilp, \" (push)\");\n+\t}\n \n \treturn 0;\n }\n@@ -1291,6 +1308,7 @@ static int get_one_entry(struct remote *remote, void *priv)\n static int show_all(void)\n {\n \tstruct string_list list = { NULL, 0, 0 };\n+\tlist.strdup_strings = 1;\n \tint result = for_each_remote(get_one_entry, &list);\n \n \tif (!result) {\n@@ -1309,6 +1327,7 @@ static int show_all(void)\n \t\t\t}\n \t\t}\n \t}\n+\tstring_list_clear(&list, 1);\n \treturn result;\n }\n \n-- \n1.6.3.2.278.gb6431.dirty\n"},{"id":"115918","messageId":"7vvdn5nzmb.fsf@alter.siamese.dyndns.org","threadId":"19762","inReplyTo":"1244563298-15479-6-git-send-email-git@drmicha.warpmail.net","subject":"Re: [PATCH 5/5] builtin-remote: Make \"remote -v\" display push urls","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-09T16:25:16Z","receivedAt":"2009-06-09T16:25:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Example with \"mjg\" having 1 url and 1 pushurl, \"origin\" having 3 urls,\n> sb having 1 url:\n>\n> mjg     git://repo.or.cz/git/mjg.git (fetch)\n> mjg     repoor:/srv/git/git/mjg.git (push)\n> origin  git://repo.or.cz/git.git (fetch)\n> origin  git://repo.or.cz/git.git (push)\n> origin  git://git2.kernel.org/pub/scm/git/git.git (push)\n> origin  git://repo.or.cz/alt-git.git (push)\n> sb      git://repo.or.cz/git/sbeyer.git (fetch)\n> sb      git://repo.or.cz/git/sbeyer.git (push)\n\nThe readers will get distracted, saying \"eh, git:// can be used for push?\"\n(and the answer is \"yes, sometimes, but not for repo.or.cz\") even though\nthat is not the point of these illustrations.  For these examles, I think\nit is better to use \"repo.or.cz:foo.git\" style, instead of \"git://\".\n\nI am debating myself if the last two should be just one line,\nwithout \"(fetch)\" nor \"(push)\" tacked at the end, like this:\n\n        sb     git://repo.or.cz/git/sbeyer.git\n\nIf we change the rule in your patch to format a remote.*.url used for both\npush and fetch as a single line to achieve this, however, it would make\nyour \"origin\" example come out like this instead:\n\n\torigin git://repo.or.cz/git.git\n        origin git://git.kernel.org/pub/scm/git/git.git (push)\n        origin git://repo.or.cz/alt-git.git (push)\n\nwhich is arguably better (one less line) and worse (it is unclear if the\ntop one is only for fetching) at the same time.\n\nOr perhaps we could go with something like this.\n\n\torigin git://repo.or.cz/git.git (fetch/push)\n        origin git://git.kernel.org/pub/scm/git/git.git (push)\n        origin git://repo.or.cz/alt-git.git (push)\n        sb     git://repo.or.cz/git/sbeyer.git\n\ni.e. make the rule such that a URL used for both are shown with (fetch/push)\nonly if there are other lines for the same remote.\n\nHmm?\n"},{"id":"115919","messageId":"36ca99e90906090925q71ed98f4j23336dabbe199bd8@mail.gmail.com","threadId":"19762","inReplyTo":"1244563298-15479-6-git-send-email-git@drmicha.warpmail.net","subject":"Re: [PATCH 5/5] builtin-remote: Make \"remote -v\" display push urls","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2009-06-09T16:25:41Z","receivedAt":"2009-06-09T16:25:41Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Hi,\n\nOn Tue, Jun 9, 2009 at 18:01, Michael J Gruber<git@drmicha.warpmail.net> wrote:\n> Currently, \"remote -v\" simply lists all urls so that one has to remember\n> that only the first one is used for fetches, and all are used for\n> pushes.\n>\n> Change this so that the role of an url is displayed in parentheses, and\n> also display push urls.\n>\n> Example with \"mjg\" having 1 url and 1 pushurl, \"origin\" having 3 urls,\n> sb having 1 url:\n>\n> mjg     git://repo.or.cz/git/mjg.git (fetch)\n> mjg     repoor:/srv/git/git/mjg.git (push)\n> origin  git://repo.or.cz/git.git (fetch)\n> origin  git://repo.or.cz/git.git (push)\n> origin  git://git2.kernel.org/pub/scm/git/git.git (push)\n> origin  git://repo.or.cz/alt-git.git (push)\n> sb      git://repo.or.cz/git/sbeyer.git (fetch)\n> sb      git://repo.or.cz/git/sbeyer.git (push)\n\nWouldn't it be more readable if push|fetch comes first?\n\nmjg     (fetch) git://repo.or.cz/git/mjg.git\nmjg     (push)  repoor:/srv/git/git/mjg.git\norigin  (fetch) git://repo.or.cz/git.git\norigin  (push)  git://repo.or.cz/git.git\norigin  (push)  git://git2.kernel.org/pub/scm/git/git.git\norigin  (push)  git://repo.or.cz/alt-git.git\nsb      (fetch) git://repo.or.cz/git/sbeyer.git\nsb      (push)  git://repo.or.cz/git/sbeyer.git\n\nAnd how about to print only one line for (url_nr == 1 && pushurl_nr == 0):\n\nmjg     (fetch) git://repo.or.cz/git/mjg.git\nmjg     (push)  repoor:/srv/git/git/mjg.git\norigin  (fetch) git://repo.or.cz/git.git\norigin  (push)  git://repo.or.cz/git.git\norigin  (push)  git://git2.kernel.org/pub/scm/git/git.git\norigin  (push)  git://repo.or.cz/alt-git.git\nsb              git://repo.or.cz/git/sbeyer.git\n\n>\n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> ---\n>  builtin-remote.c |   27 +++++++++++++++++++++++----\n>  1 files changed, 23 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin-remote.c b/builtin-remote.c\n> index b350b18..80b2536 100644\n> --- a/builtin-remote.c\n> +++ b/builtin-remote.c\n> @@ -1276,14 +1276,31 @@ static int update(int argc, const char **argv)\n>  static int get_one_entry(struct remote *remote, void *priv)\n>  {\n>        struct string_list *list = priv;\n> +       const char **url;\n> +       int i, url_nr;\n> +       void **utilp;\n>\n>        if (remote->url_nr > 0) {\n> -               int i;\n> -\n> -               for (i = 0; i < remote->url_nr; i++)\n> -                       string_list_append(remote->name, list)->util = (void *)remote->url[i];\n> +               utilp = &(string_list_append(remote->name, list)->util);\n> +               *utilp = malloc(strlen(remote->url[0])+strlen(\" (fetch)\")+1);\n> +               strcpy((char *) *utilp, remote->url[0]);\n> +               strcat((char *) *utilp, \" (fetch)\");\nHow about using struct strbuf?\n\nBert\n"},{"id":"115926","messageId":"4A2EA04D.9080405@drmicha.warpmail.net","threadId":"19762","inReplyTo":"7vvdn5nzmb.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 5/5] builtin-remote: Make \"remote -v\" display push urls","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-09T17:47:57Z","receivedAt":"2009-06-09T17:47:57Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Junio C Hamano venit, vidit, dixit 09.06.2009 18:25:\n> Michael J Gruber <git@drmicha.warpmail.net> writes:\n> \n>> Example with \"mjg\" having 1 url and 1 pushurl, \"origin\" having 3 urls,\n>> sb having 1 url:\n>>\n>> mjg     git://repo.or.cz/git/mjg.git (fetch)\n>> mjg     repoor:/srv/git/git/mjg.git (push)\n>> origin  git://repo.or.cz/git.git (fetch)\n>> origin  git://repo.or.cz/git.git (push)\n>> origin  git://git2.kernel.org/pub/scm/git/git.git (push)\n>> origin  git://repo.or.cz/alt-git.git (push)\n>> sb      git://repo.or.cz/git/sbeyer.git (fetch)\n>> sb      git://repo.or.cz/git/sbeyer.git (push)\n> \n> The readers will get distracted, saying \"eh, git:// can be used for push?\"\n> (and the answer is \"yes, sometimes, but not for repo.or.cz\") even though\n> that is not the point of these illustrations.  For these examles, I think\n> it is better to use \"repo.or.cz:foo.git\" style, instead of \"git://\".\n\nUhm, isn't host:foo.git equivalent to ssh://host/foo.git?\n\nIn any case, if you clone from a fetch-only url (which is the typical\nhead start) then the default push url does not work (like sb above),\nbefore as well as after this series.\n\nI noticed that I left an URL alias (\"repoor\" = \"repoor:/srv/git/\" plus\nssh config for \"repoor\") in that example which isn't great either...\nMaybe I should just use generic domains (example.com).\n\nI'll answer to the other points in a different reply.\n\nMichael\n"},{"id":"115929","messageId":"4A2EA4EA.1070107@drmicha.warpmail.net","threadId":"19762","inReplyTo":"36ca99e90906090925q71ed98f4j23336dabbe199bd8@mail.gmail.com","subject":"Re: [PATCH 5/5] builtin-remote: Make \"remote -v\" display push urls","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-09T18:07:38Z","receivedAt":"2009-06-09T18:07:38Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"> On Tue, Jun 9, 2009 at 18:01, Michael J Gruber<git@drmicha.warpmail.net> wrote:\n>> Currently, \"remote -v\" simply lists all urls so that one has to remember\n>> that only the first one is used for fetches, and all are used for\n>> pushes.\n>>\n>> Change this so that the role of an url is displayed in parentheses, and\n>> also display push urls.\n>>\n>> Example with \"mjg\" having 1 url and 1 pushurl, \"origin\" having 3 urls,\n>> sb having 1 url:\n>>\n>> mjg     git://repo.or.cz/git/mjg.git (fetch)\n>> mjg     repoor:/srv/git/git/mjg.git (push)\n>> origin  git://repo.or.cz/git.git (fetch)\n>> origin  git://repo.or.cz/git.git (push)\n>> origin  git://git2.kernel.org/pub/scm/git/git.git (push)\n>> origin  git://repo.or.cz/alt-git.git (push)\n>> sb      git://repo.or.cz/git/sbeyer.git (fetch)\n>> sb      git://repo.or.cz/git/sbeyer.git (push)\n\nJunio wrote:\n> I am debating myself if the last two should be just one line,\n> without \"(fetch)\" nor \"(push)\" tacked at the end, like this:\n> \n>         sb     git://repo.or.cz/git/sbeyer.git\n> \n> If we change the rule in your patch to format a remote.*.url used for both\n> push and fetch as a single line to achieve this, however, it would make\n> your \"origin\" example come out like this instead:\n> \n> \torigin git://repo.or.cz/git.git\n>         origin git://git.kernel.org/pub/scm/git/git.git (push)\n>         origin git://repo.or.cz/alt-git.git (push)\n> \n> which is arguably better (one less line) and worse (it is unclear if the\n> top one is only for fetching) at the same time.\n> \n> Or perhaps we could go with something like this.\n> \n> \torigin git://repo.or.cz/git.git (fetch/push)\n>         origin git://git.kernel.org/pub/scm/git/git.git (push)\n>         origin git://repo.or.cz/alt-git.git (push)\n>         sb     git://repo.or.cz/git/sbeyer.git\n> \n> i.e. make the rule such that a URL used for both are shown with (fetch/push)\n> only if there are other lines for the same remote.\n\nBert wrote:\n> Wouldn't it be more readable if push|fetch comes first?\n> \n> mjg     (fetch) git://repo.or.cz/git/mjg.git\n> mjg     (push)  repoor:/srv/git/git/mjg.git\n> origin  (fetch) git://repo.or.cz/git.git\n> origin  (push)  git://repo.or.cz/git.git\n> origin  (push)  git://git2.kernel.org/pub/scm/git/git.git\n> origin  (push)  git://repo.or.cz/alt-git.git\n> sb      (fetch) git://repo.or.cz/git/sbeyer.git\n> sb      (push)  git://repo.or.cz/git/sbeyer.git\n> \n> And how about to print only one line for (url_nr == 1 && pushurl_nr == 0):\n> \n> mjg     (fetch) git://repo.or.cz/git/mjg.git\n> mjg     (push)  repoor:/srv/git/git/mjg.git\n> origin  (fetch) git://repo.or.cz/git.git\n> origin  (push)  git://repo.or.cz/git.git\n> origin  (push)  git://git2.kernel.org/pub/scm/git/git.git\n> origin  (push)  git://repo.or.cz/alt-git.git\n> sb              git://repo.or.cz/git/sbeyer.git\n> \n\nAll this shows why this one is 5/5 and separate ;) I was thinking hard\nabout the best display also. From my point of view, there are two\narguments against the seemingly more user friendly variants (collapsing\nfetch and push entries with the same url):\n\n- It introduces 3 different types of lines, rather than 2.\n- The code would have to go through all (push) urls and check whether it\nmatches url[0].\n\nWhile the latter one is technical, the first makes it more difficult to\nparse the output, both visually and programmatically (I know, porc...).\n\nNote that at least implicitely we always had 2 different types of lines\nin the output of \"remote -v\": the first one (fetch+push) and the others\n(push). There is no way to keep only those 2 types (when there is a\n\"pushurl\" setting), my suggestion was to use 2 types now for the 2 purposes.\n\n>>\n>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n>> ---\n>>  builtin-remote.c |   27 +++++++++++++++++++++++----\n>>  1 files changed, 23 insertions(+), 4 deletions(-)\n>>\n>> diff --git a/builtin-remote.c b/builtin-remote.c\n>> index b350b18..80b2536 100644\n>> --- a/builtin-remote.c\n>> +++ b/builtin-remote.c\n>> @@ -1276,14 +1276,31 @@ static int update(int argc, const char **argv)\n>>  static int get_one_entry(struct remote *remote, void *priv)\n>>  {\n>>        struct string_list *list = priv;\n>> +       const char **url;\n>> +       int i, url_nr;\n>> +       void **utilp;\n>>\n>>        if (remote->url_nr > 0) {\n>> -               int i;\n>> -\n>> -               for (i = 0; i < remote->url_nr; i++)\n>> -                       string_list_append(remote->name, list)->util = (void *)remote->url[i];\n>> +               utilp = &(string_list_append(remote->name, list)->util);\n>> +               *utilp = malloc(strlen(remote->url[0])+strlen(\" (fetch)\")+1);\n>> +               strcpy((char *) *utilp, remote->url[0]);\n>> +               strcat((char *) *utilp, \" (fetch)\");\n> How about using struct strbuf?\n\nI thought it's complicated enough for the little change in output... But\nwhat do strbufs bring us here?\nBefore the patch, builtin-remote would leak the string_list. They way I\nuse malloc enables me to free the string list (using string_list_clear)\nlater on, including the strings and utils. strcpy and strcat look a bit\nlow level but I see no point in using the sprintf shotgun here.\n\nMore or less I have zero clue about strbuf (OK, probably not less...)\nbut I think that if util is a strbuf then freeing everything would be\nmore complicated because a strbuf may or may not be allocated.\n\nMichael\n"},{"id":"115931","messageId":"7vtz2pmf98.fsf@alter.siamese.dyndns.org","threadId":"19762","inReplyTo":"4A2EA04D.9080405@drmicha.warpmail.net","subject":"Re: [PATCH 5/5] builtin-remote: Make \"remote -v\" display push urls","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-09T18:30:27Z","receivedAt":"2009-06-09T18:30:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Junio C Hamano venit, vidit, dixit 09.06.2009 18:25:\n>> Michael J Gruber <git@drmicha.warpmail.net> writes:\n>> \n>>> Example with \"mjg\" having 1 url and 1 pushurl, \"origin\" having 3 urls,\n>>> sb having 1 url:\n>>>\n>>> mjg     git://repo.or.cz/git/mjg.git (fetch)\n>>> mjg     repoor:/srv/git/git/mjg.git (push)\n>>> origin  git://repo.or.cz/git.git (fetch)\n>>> origin  git://repo.or.cz/git.git (push)\n>>> origin  git://git2.kernel.org/pub/scm/git/git.git (push)\n>>> origin  git://repo.or.cz/alt-git.git (push)\n>>> sb      git://repo.or.cz/git/sbeyer.git (fetch)\n>>> sb      git://repo.or.cz/git/sbeyer.git (push)\n>> \n>> The readers will get distracted, saying \"eh, git:// can be used for push?\"\n>> (and the answer is \"yes, sometimes, but not for repo.or.cz\") even though\n>> that is not the point of these illustrations.  For these examles, I think\n>> it is better to use \"repo.or.cz:foo.git\" style, instead of \"git://\".\n>\n> Uhm, isn't host:foo.git equivalent to ssh://host/foo.git?\n\nThe primary point is git:// is usually considered read-only and not for\npush.  I personally am more used to host:repo and that is why I wrote it\nthat way; besides, the second line in your example already uses that\nnotation, not the ssh:// one.\n"},{"id":"116239","messageId":"1244910551-4420-1-git-send-email-git@drmicha.warpmail.net","threadId":"19762","inReplyTo":"7vtz2pmf98.fsf@alter.siamese.dyndns.org","subject":"[PATCHv2 0/5] builtin-remote: Make \"remote -v\" display push urls","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-13T16:29:09Z","receivedAt":"2009-06-13T16:29:09Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"So here are v2 of 4/5 and 5/5: Only the commit messages are revised\naccording to the discussion. The one of 5/5 uses a better example, and\nthe one of 4/5 shows the output for the same example now (before it had\nno example). Patch-ids unchanged. 1/5, 2/5 and 3/5 are completely\nunchanged and, thus, unsent :)\n\nCheers,\nMichael\n\nMichael J Gruber (2):\n  builtin-remote: Show push urls as well\n  builtin-remote: Make \"remote -v\" display push urls\n\n builtin-remote.c  |   47 ++++++++++++++++++++++++++++++++++++++---------\n t/t5505-remote.sh |   10 +++++++---\n 2 files changed, 45 insertions(+), 12 deletions(-)\n"},{"id":"116238","messageId":"1244910551-4420-2-git-send-email-git@drmicha.warpmail.net","threadId":"19762","inReplyTo":"1244910551-4420-1-git-send-email-git@drmicha.warpmail.net","subject":"[PATCHv2 4/5] builtin-remote: Show push urls as well","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-13T16:29:10Z","receivedAt":"2009-06-13T16:29:10Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Teach builtin remote to show push urls also when asked to\n\"show\" a specific remote.\n\nThis improves upon the standard display mode: multiple specified \"url\"s\nmean that the first one is for fetching, all are used for pushing. We\nmake this clearer now by displaying the first one prefixed with \"Fetch\nURL\", and all \"url\"s (or, if present, all \"pushurl\"s) prefixed with\n\"Push  URL\".\n\nExample with \"one\" having one url, \"two\" two urls, \"three\" one url and\none pushurl (URL part only):\n\n* remote one\n  Fetch URL: hostone.com:/somepath/repoone.git\n  Push  URL: hostone.com:/somepath/repoone.git\n* remote two\n  Fetch URL: hosttwo.com:/somepath/repotwo.git\n  Push  URL: hosttwo.com:/somepath/repotwo.git\n  Push  URL: hosttwobackup.com:/somewheresafe/repotwo.git\n* remote three\n  Fetch URL: http://hostthree.com/otherpath/repothree.git\n  Push  URL: hostthree.com:/pathforpushes/repothree.git\n\nAlso, adjust t5505 accordingly and make it test for the new output.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n builtin-remote.c  |   20 +++++++++++++++-----\n t/t5505-remote.sh |   10 +++++++---\n 2 files changed, 22 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex dfc0b9e..b350b18 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -999,15 +999,25 @@ static int show(int argc, const char **argv)\n \tinfo.list = &info_list;\n \tfor (; argc; argc--, argv++) {\n \t\tint i;\n+\t\tconst char **url;\n+\t\tint url_nr;\n \n \t\tget_remote_ref_states(*argv, &states, query_flag);\n \n \t\tprintf(\"* remote %s\\n\", *argv);\n-\t\tif (states.remote->url_nr) {\n-\t\t\tfor (i=0; i < states.remote->url_nr; i++)\n-\t\t\t\tprintf(\"  URL: %s\\n\", states.remote->url[i]);\n-\t\t} else\n-\t\t\tprintf(\"  URL: %s\\n\", \"(no URL)\");\n+\t\tprintf(\"  Fetch URL: %s\\n\", states.remote->url_nr > 0 ?\n+\t\t\tstates.remote->url[0] : \"(no URL)\");\n+\t\tif (states.remote->pushurl_nr) {\n+\t\t\turl = states.remote->pushurl;\n+\t\t\turl_nr = states.remote->pushurl_nr;\n+\t\t} else {\n+\t\t\turl = states.remote->url;\n+\t\t\turl_nr = states.remote->url_nr;\n+\t\t}\n+\t\tfor (i=0; i < url_nr; i++)\n+\t\t\tprintf(\"  Push  URL: %s\\n\", url[i]);\n+\t\tif (!i)\n+\t\t\tprintf(\"  Push  URL: %s\\n\", \"(no URL)\");\n \t\tif (no_query)\n \t\t\tprintf(\"  HEAD branch: (not queried)\\n\");\n \t\telse if (!states.heads.nr)\ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex e70246b..852ccb5 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -135,7 +135,8 @@ EOF\n \n cat > test/expect << EOF\n * remote origin\n-  URL: $(pwd)/one\n+  Fetch URL: $(pwd)/one\n+  Push  URL: $(pwd)/one\n   HEAD branch: master\n   Remote branches:\n     master new (next fetch will store in remotes/origin)\n@@ -151,7 +152,8 @@ cat > test/expect << EOF\n     master pushes to master   (local out of date)\n     master pushes to upstream (create)\n * remote two\n-  URL: ../two\n+  Fetch URL: ../two\n+  Push  URL: ../three\n   HEAD branch (remote HEAD is ambiguous, may be one of the following):\n     another\n     master\n@@ -173,6 +175,7 @@ test_expect_success 'show' '\n \t git branch --track rebase origin/master &&\n \t git branch -d -r origin/master &&\n \t git config --add remote.two.url ../two &&\n+\t git config --add remote.two.pushurl ../three &&\n \t git config branch.rebase.rebase true &&\n \t git config branch.octopus.merge \"topic-a topic-b topic-c\" &&\n \t (cd ../one &&\n@@ -191,7 +194,8 @@ test_expect_success 'show' '\n \n cat > test/expect << EOF\n * remote origin\n-  URL: $(pwd)/one\n+  Fetch URL: $(pwd)/one\n+  Push  URL: $(pwd)/one\n   HEAD branch: (not queried)\n   Remote branches: (status not queried)\n     master\n-- \n1.6.3.2.367.gf0de\n"},{"id":"116240","messageId":"1244910551-4420-3-git-send-email-git@drmicha.warpmail.net","threadId":"19762","inReplyTo":"1244910551-4420-2-git-send-email-git@drmicha.warpmail.net","subject":"[PATCHv2 5/5] builtin-remote: Make \"remote -v\" display push urls","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-06-13T16:29:11Z","receivedAt":"2009-06-13T16:29:11Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Currently, \"remote -v\" simply lists all urls so that one has to remember\nthat only the first one is used for fetches, and all are used for\npushes.\n\nChange this so that the role of an url is displayed in parentheses, and\nalso display push urls.\n\nExample with \"one\" having one url, \"two\" two urls, \"three\" one url and\none pushurl:\n\none     hostone.com:/somepath/repoone.git (fetch)\none     hostone.com:/somepath/repoone.git (push)\nthree   http://hostthree.com/otherpath/repothree.git (fetch)\nthree   hostthree.com:/pathforpushes/repothree.git (push)\ntwo     hosttwo.com:/somepath/repotwo.git (fetch)\ntwo     hosttwo.com:/somepath/repotwo.git (push)\ntwo     hosttwobackup.com:/somewheresafe/repotwo.git (push)\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n builtin-remote.c |   27 +++++++++++++++++++++++----\n 1 files changed, 23 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex b350b18..80b2536 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -1276,14 +1276,31 @@ static int update(int argc, const char **argv)\n static int get_one_entry(struct remote *remote, void *priv)\n {\n \tstruct string_list *list = priv;\n+\tconst char **url;\n+\tint i, url_nr;\n+\tvoid **utilp;\n \n \tif (remote->url_nr > 0) {\n-\t\tint i;\n-\n-\t\tfor (i = 0; i < remote->url_nr; i++)\n-\t\t\tstring_list_append(remote->name, list)->util = (void *)remote->url[i];\n+\t\tutilp = &(string_list_append(remote->name, list)->util);\n+\t\t*utilp = malloc(strlen(remote->url[0])+strlen(\" (fetch)\")+1);\n+\t\tstrcpy((char *) *utilp, remote->url[0]);\n+\t\tstrcat((char *) *utilp, \" (fetch)\");\n \t} else\n \t\tstring_list_append(remote->name, list)->util = NULL;\n+\tif (remote->pushurl_nr) {\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+\tfor (i = 0; i < url_nr; i++)\n+\t{\n+\t\tutilp = &(string_list_append(remote->name, list)->util);\n+\t\t*utilp = malloc(strlen(url[i])+strlen(\" (push)\")+1);\n+\t\tstrcpy((char *) *utilp, url[i]);\n+\t\tstrcat((char *) *utilp, \" (push)\");\n+\t}\n \n \treturn 0;\n }\n@@ -1291,6 +1308,7 @@ static int get_one_entry(struct remote *remote, void *priv)\n static int show_all(void)\n {\n \tstruct string_list list = { NULL, 0, 0 };\n+\tlist.strdup_strings = 1;\n \tint result = for_each_remote(get_one_entry, &list);\n \n \tif (!result) {\n@@ -1309,6 +1327,7 @@ static int show_all(void)\n \t\t\t}\n \t\t}\n \t}\n+\tstring_list_clear(&list, 1);\n \treturn result;\n }\n \n-- \n1.6.3.2.367.gf0de\n"},{"id":"116266","messageId":"7vprd7s6lf.fsf@alter.siamese.dyndns.org","threadId":"19762","inReplyTo":"1244910551-4420-3-git-send-email-git@drmicha.warpmail.net","subject":"Re: [PATCHv2 5/5] builtin-remote: Make \"remote -v\" display push urls","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-14T05:54:36Z","receivedAt":"2009-06-14T05:54:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks, will replace with these two and merge to 'next'.\n\nI'll squash this in to [5/5], which is the same fix-up as I queued the\nprevious round to 'pu', to avoid decl-after-statement, by the way.\n\n builtin-remote.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex f377722..3f6f5c2 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -1311,8 +1311,10 @@ static int get_one_entry(struct remote *remote, void *priv)\n static int show_all(void)\n {\n \tstruct string_list list = { NULL, 0, 0 };\n+\tint result;\n+\n \tlist.strdup_strings = 1;\n-\tint result = for_each_remote(get_one_entry, &list);\n+\tresult = for_each_remote(get_one_entry, &list);\n \n \tif (!result) {\n \t\tint i;\n"}]}