@matheusbsbs / matheus-bagliano / commits / 4a4b4cdaab
Fork 0

builtin-remote: Make "remote -v" display push urls

Currently, "remote -v" simply lists all urls so that one has to remember that only the first one is used for fetches, and all are used for pushes. Change this so that the role of an url is displayed in parentheses, and also display push urls. Example with "one" having one url, "two" two urls, "three" one url and one pushurl: one hostone.com:/somepath/repoone.git (fetch) one hostone.com:/somepath/repoone.git (push) three http://hostthree.com/otherpath/repothree.git (fetch) three hostthree.com:/pathforpushes/repothree.git (push) two hosttwo.com:/somepath/repotwo.git (fetch) two hosttwo.com:/somepath/repotwo.git (push) two hosttwobackup.com:/somewheresafe/repotwo.git (push) 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 4a4b4cdaabde477514c4938b60961538e1d2d91f
1 file changed +26 -5
builtin-remote.c
+26 -5
@@ -1279,14 +1279,31 @@ static int update(int argc, const char **argv)
1279 static int get_one_entry(struct remote *remote, void *priv)
1280 {
1281 struct string_list *list = priv;
1282 + const char **url;
1283 + int i, url_nr;
1284 + void **utilp;
1285
1286 if (remote->url_nr > 0) {
1284 - int i;
1285 -
1286 - for (i = 0; i < remote->url_nr; i++)
1287 - string_list_append(remote->name, list)->util = (void *)remote->url[i];
1287 + utilp = &(string_list_append(remote->name, list)->util);
1288 + *utilp = malloc(strlen(remote->url[0])+strlen(" (fetch)")+1);
1289 + strcpy((char *) *utilp, remote->url[0]);
1290 + strcat((char *) *utilp, " (fetch)");
1291 } else
1292 string_list_append(remote->name, list)->util = NULL;
1293 + if (remote->pushurl_nr) {
1294 + url = remote->pushurl;
1295 + url_nr = remote->pushurl_nr;
1296 + } else {
1297 + url = remote->url;
1298 + url_nr = remote->url_nr;
1299 + }
1300 + for (i = 0; i < url_nr; i++)
1301 + {
1302 + utilp = &(string_list_append(remote->name, list)->util);
1303 + *utilp = malloc(strlen(url[i])+strlen(" (push)")+1);
1304 + strcpy((char *) *utilp, url[i]);
1305 + strcat((char *) *utilp, " (push)");
1306 + }
1307
1308 return 0;
1309 }
@@ -1294,7 +1311,10 @@ static int get_one_entry(struct remote *remote, void *priv)
1311 static int show_all(void)
1312 {
1313 struct string_list list = { NULL, 0, 0 };
1297 - int result = for_each_remote(get_one_entry, &list);
1314 + int result;
1315 +
1316 + list.strdup_strings = 1;
1317 + result = for_each_remote(get_one_entry, &list);
1318
1319 if (!result) {
1320 int i;
@@ -1312,6 +1332,7 @@ static int show_all(void)
1332 }
1333 }
1334 }
1335 + string_list_clear(&list, 1);
1336 return result;
1337 }
1338