Skip to content

Commit 7d20e21

Browse files
Michael J Grubergitster
authored andcommitted
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>
1 parent 1f5a892 commit 7d20e21

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

builtin-remote.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,13 @@ static int get_one_entry(struct remote *remote, void *priv)
652652
{
653653
struct string_list *list = priv;
654654

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;
659662

660663
return 0;
661664
}
@@ -671,10 +674,14 @@ static int show_all(void)
671674
sort_string_list(&list);
672675
for (i = 0; i < list.nr; i++) {
673676
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+
}
678685
}
679686
}
680687
return result;

0 commit comments

Comments
 (0)