make "git remote" report multiple URLs
This patch makes "git remote -v" and "git remote show" report multiple URLs rather than warn about them. Multiple URLs are OK for pushing into multiple repos simultaneously. Without "-v" each repo is shown once only. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael J Gruber committed
Sep 22, 2008 at 10:57 UTC
7d20e2189e19f51662353ea853891e00882d29cc
1 file changed
+15
-8
builtin-remote.c
+15
-8
@@ -652,10 +652,13 @@ static int get_one_entry(struct remote *remote, void *priv)
652
{
653
struct string_list *list = priv;
654
655
- string_list_append(remote->name, list)->util = remote->url_nr ?
656
- (void *)remote->url[0] : NULL;
657
- if (remote->url_nr > 1)
658
- warning("Remote %s has more than one URL", remote->name);
655
+ if (remote->url_nr > 0) {
656
+ int i;
657
+
658
+ for (i = 0; i < remote->url_nr; i++)
659
+ string_list_append(remote->name, list)->util = (void *)remote->url[i];
660
+ } else
661
+ string_list_append(remote->name, list)->util = NULL;
662
663
return 0;
664
}
@@ -671,10 +674,14 @@ static int show_all(void)
674
sort_string_list(&list);
675
for (i = 0; i < list.nr; i++) {
676
struct string_list_item *item = list.items + i;
674
- printf("%s%s%s\n", item->string,
675
- verbose ? "\t" : "",
676
- verbose && item->util ?
677
- (const char *)item->util : "");
677
+ if (verbose)
678
+ printf("%s\t%s\n", item->string,
679
+ item->util ? (const char *)item->util : "");
680
+ else {
681
+ if (i && !strcmp((item - 1)->string, item->string))
682
+ continue;
683
+ printf("%s\n", item->string);
684
+ }
685
}
686
}
687
return result;