Skip to content

Commit 4a4b4cd

Browse files
Michael J Grubergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 857f8c3 commit 4a4b4cd

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

builtin-remote.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,22 +1279,42 @@ static int update(int argc, const char **argv)
12791279
static int get_one_entry(struct remote *remote, void *priv)
12801280
{
12811281
struct string_list *list = priv;
1282+
const char **url;
1283+
int i, url_nr;
1284+
void **utilp;
12821285

12831286
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)");
12881291
} else
12891292
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+
}
12901307

12911308
return 0;
12921309
}
12931310

12941311
static int show_all(void)
12951312
{
12961313
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);
12981318

12991319
if (!result) {
13001320
int i;
@@ -1312,6 +1332,7 @@ static int show_all(void)
13121332
}
13131333
}
13141334
}
1335+
string_list_clear(&list, 1);
13151336
return result;
13161337
}
13171338

0 commit comments

Comments
 (0)