@matheusbsbs / matheus-bagliano / commits / 857f8c30d7
Fork 0

builtin-remote: Show push urls as well

Teach builtin remote to show push urls also when asked to "show" a specific remote. This improves upon the standard display mode: multiple specified "url"s mean that the first one is for fetching, all are used for pushing. We make this clearer now by displaying the first one prefixed with "Fetch URL", and all "url"s (or, if present, all "pushurl"s) prefixed with "Push URL". Example with "one" having one url, "two" two urls, "three" one url and one pushurl (URL part only): * remote one Fetch URL: hostone.com:/somepath/repoone.git Push URL: hostone.com:/somepath/repoone.git * remote two Fetch URL: hosttwo.com:/somepath/repotwo.git Push URL: hosttwo.com:/somepath/repotwo.git Push URL: hosttwobackup.com:/somewheresafe/repotwo.git * remote three Fetch URL: http://hostthree.com/otherpath/repothree.git Push URL: hostthree.com:/pathforpushes/repothree.git Also, adjust t5505 accordingly and make it test for the new output. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Jun 13, 2009 at 18:29 UTC 857f8c30d79ce15b6110b0df9d3ad87075ca5153
2 files changed +22 -8
builtin-remote.c
+15 -5
@@ -1002,15 +1002,25 @@ static int show(int argc, const char **argv)
1002 info.list = &info_list;
1003 for (; argc; argc--, argv++) {
1004 int i;
1005 + const char **url;
1006 + int url_nr;
1007
1008 get_remote_ref_states(*argv, &states, query_flag);
1009
1010 printf("* remote %s\n", *argv);
1009 - if (states.remote->url_nr) {
1010 - for (i=0; i < states.remote->url_nr; i++)
1011 - printf(" URL: %s\n", states.remote->url[i]);
1012 - } else
1013 - printf(" URL: %s\n", "(no URL)");
1011 + printf(" Fetch URL: %s\n", states.remote->url_nr > 0 ?
1012 + states.remote->url[0] : "(no URL)");
1013 + if (states.remote->pushurl_nr) {
1014 + url = states.remote->pushurl;
1015 + url_nr = states.remote->pushurl_nr;
1016 + } else {
1017 + url = states.remote->url;
1018 + url_nr = states.remote->url_nr;
1019 + }
1020 + for (i=0; i < url_nr; i++)
1021 + printf(" Push URL: %s\n", url[i]);
1022 + if (!i)
1023 + printf(" Push URL: %s\n", "(no URL)");
1024 if (no_query)
1025 printf(" HEAD branch: (not queried)\n");
1026 else if (!states.heads.nr)
t/t5505-remote.sh
+7 -3
@@ -135,7 +135,8 @@ EOF
135
136 cat > test/expect << EOF
137 * remote origin
138 - URL: $(pwd)/one
138 + Fetch URL: $(pwd)/one
139 + Push URL: $(pwd)/one
140 HEAD branch: master
141 Remote branches:
142 master new (next fetch will store in remotes/origin)
@@ -151,7 +152,8 @@ cat > test/expect << EOF
152 master pushes to master (local out of date)
153 master pushes to upstream (create)
154 * remote two
154 - URL: ../two
155 + Fetch URL: ../two
156 + Push URL: ../three
157 HEAD branch (remote HEAD is ambiguous, may be one of the following):
158 another
159 master
@@ -173,6 +175,7 @@ test_expect_success 'show' '
175 git branch --track rebase origin/master &&
176 git branch -d -r origin/master &&
177 git config --add remote.two.url ../two &&
178 + git config --add remote.two.pushurl ../three &&
179 git config branch.rebase.rebase true &&
180 git config branch.octopus.merge "topic-a topic-b topic-c" &&
181 (cd ../one &&
@@ -191,7 +194,8 @@ test_expect_success 'show' '
194
195 cat > test/expect << EOF
196 * remote origin
194 - URL: $(pwd)/one
197 + Fetch URL: $(pwd)/one
198 + Push URL: $(pwd)/one
199 HEAD branch: (not queried)
200 Remote branches: (status not queried)
201 master