builtin/remote.c: reorder function definitions

Reorder function definitions to remove the need for forward declarations. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Oct 30, 2013 at 06:33 UTC ce2223fde87c6df2a3d837b188d9509527de7264
1 file changed +78 -81
builtin/remote.c
+78 -81
@@ -77,9 +77,6 @@ static const char * const builtin_remote_seturl_usage[] = {
77
78 static int verbose;
79
80 -static int show_all(void);
81 -static int prune_remote(const char *remote, int dry_run);
82 -
80 static inline int postfixcmp(const char *string, const char *postfix)
81 {
82 int len1 = strlen(string), len2 = strlen(postfix);
@@ -1084,6 +1081,64 @@ static int show_push_info_item(struct string_list_item *item, void *cb_data)
1081 return 0;
1082 }
1083
1084 +static int get_one_entry(struct remote *remote, void *priv)
1085 +{
1086 + struct string_list *list = priv;
1087 + struct strbuf url_buf = STRBUF_INIT;
1088 + const char **url;
1089 + int i, url_nr;
1090 +
1091 + if (remote->url_nr > 0) {
1092 + strbuf_addf(&url_buf, "%s (fetch)", remote->url[0]);
1093 + string_list_append(list, remote->name)->util =
1094 + strbuf_detach(&url_buf, NULL);
1095 + } else
1096 + string_list_append(list, remote->name)->util = NULL;
1097 + if (remote->pushurl_nr) {
1098 + url = remote->pushurl;
1099 + url_nr = remote->pushurl_nr;
1100 + } else {
1101 + url = remote->url;
1102 + url_nr = remote->url_nr;
1103 + }
1104 + for (i = 0; i < url_nr; i++)
1105 + {
1106 + strbuf_addf(&url_buf, "%s (push)", url[i]);
1107 + string_list_append(list, remote->name)->util =
1108 + strbuf_detach(&url_buf, NULL);
1109 + }
1110 +
1111 + return 0;
1112 +}
1113 +
1114 +static int show_all(void)
1115 +{
1116 + struct string_list list = STRING_LIST_INIT_NODUP;
1117 + int result;
1118 +
1119 + list.strdup_strings = 1;
1120 + result = for_each_remote(get_one_entry, &list);
1121 +
1122 + if (!result) {
1123 + int i;
1124 +
1125 + sort_string_list(&list);
1126 + for (i = 0; i < list.nr; i++) {
1127 + struct string_list_item *item = list.items + i;
1128 + if (verbose)
1129 + printf("%s\t%s\n", item->string,
1130 + item->util ? (const char *)item->util : "");
1131 + else {
1132 + if (i && !strcmp((item - 1)->string, item->string))
1133 + continue;
1134 + printf("%s\n", item->string);
1135 + }
1136 + }
1137 + }
1138 + string_list_clear(&list, 1);
1139 + return result;
1140 +}
1141 +
1142 static int show(int argc, const char **argv)
1143 {
1144 int no_query = 0, result = 0, query_flag = 0;
@@ -1246,26 +1301,6 @@ static int set_head(int argc, const char **argv)
1301 return result;
1302 }
1303
1249 -static int prune(int argc, const char **argv)
1250 -{
1251 - int dry_run = 0, result = 0;
1252 - struct option options[] = {
1253 - OPT__DRY_RUN(&dry_run, N_("dry run")),
1254 - OPT_END()
1255 - };
1256 -
1257 - argc = parse_options(argc, argv, NULL, options, builtin_remote_prune_usage,
1258 - 0);
1259 -
1260 - if (argc < 1)
1261 - usage_with_options(builtin_remote_prune_usage, options);
1262 -
1263 - for (; argc; argc--, argv++)
1264 - result |= prune_remote(*argv, dry_run);
1265 -
1266 - return result;
1267 -}
1268 -
1304 static int prune_remote(const char *remote, int dry_run)
1305 {
1306 int result = 0, i;
@@ -1304,6 +1339,26 @@ static int prune_remote(const char *remote, int dry_run)
1339 return result;
1340 }
1341
1342 +static int prune(int argc, const char **argv)
1343 +{
1344 + int dry_run = 0, result = 0;
1345 + struct option options[] = {
1346 + OPT__DRY_RUN(&dry_run, N_("dry run")),
1347 + OPT_END()
1348 + };
1349 +
1350 + argc = parse_options(argc, argv, NULL, options, builtin_remote_prune_usage,
1351 + 0);
1352 +
1353 + if (argc < 1)
1354 + usage_with_options(builtin_remote_prune_usage, options);
1355 +
1356 + for (; argc; argc--, argv++)
1357 + result |= prune_remote(*argv, dry_run);
1358 +
1359 + return result;
1360 +}
1361 +
1362 static int get_remote_default(const char *key, const char *value, void *priv)
1363 {
1364 if (strcmp(key, "remotes.default") == 0) {
@@ -1505,64 +1560,6 @@ static int set_url(int argc, const char **argv)
1560 return 0;
1561 }
1562
1508 -static int get_one_entry(struct remote *remote, void *priv)
1509 -{
1510 - struct string_list *list = priv;
1511 - struct strbuf url_buf = STRBUF_INIT;
1512 - const char **url;
1513 - int i, url_nr;
1514 -
1515 - if (remote->url_nr > 0) {
1516 - strbuf_addf(&url_buf, "%s (fetch)", remote->url[0]);
1517 - string_list_append(list, remote->name)->util =
1518 - strbuf_detach(&url_buf, NULL);
1519 - } else
1520 - string_list_append(list, remote->name)->util = NULL;
1521 - if (remote->pushurl_nr) {
1522 - url = remote->pushurl;
1523 - url_nr = remote->pushurl_nr;
1524 - } else {
1525 - url = remote->url;
1526 - url_nr = remote->url_nr;
1527 - }
1528 - for (i = 0; i < url_nr; i++)
1529 - {
1530 - strbuf_addf(&url_buf, "%s (push)", url[i]);
1531 - string_list_append(list, remote->name)->util =
1532 - strbuf_detach(&url_buf, NULL);
1533 - }
1534 -
1535 - return 0;
1536 -}
1537 -
1538 -static int show_all(void)
1539 -{
1540 - struct string_list list = STRING_LIST_INIT_NODUP;
1541 - int result;
1542 -
1543 - list.strdup_strings = 1;
1544 - result = for_each_remote(get_one_entry, &list);
1545 -
1546 - if (!result) {
1547 - int i;
1548 -
1549 - sort_string_list(&list);
1550 - for (i = 0; i < list.nr; i++) {
1551 - struct string_list_item *item = list.items + i;
1552 - if (verbose)
1553 - printf("%s\t%s\n", item->string,
1554 - item->util ? (const char *)item->util : "");
1555 - else {
1556 - if (i && !strcmp((item - 1)->string, item->string))
1557 - continue;
1558 - printf("%s\n", item->string);
1559 - }
1560 - }
1561 - }
1562 - string_list_clear(&list, 1);
1563 - return result;
1564 -}
1565 -
1563 int cmd_remote(int argc, const char **argv, const char *prefix)
1564 {
1565 struct option options[] = {