Skip to content

Commit a174334

Browse files
jonathantanmygitster
authored andcommitted
fetch: refactor calculation of remote list
Separate out the calculation of remotes to be fetched from and the actual fetching. This will allow us to include an additional step before the actual fetching in a subsequent commit. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0b6069f commit a174334

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

builtin/fetch.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
13221322
{
13231323
int i;
13241324
struct string_list list = STRING_LIST_INIT_DUP;
1325-
struct remote *remote;
1325+
struct remote *remote = NULL;
13261326
int result = 0;
13271327
struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
13281328

@@ -1367,32 +1367,34 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
13671367
else if (argc > 1)
13681368
die(_("fetch --all does not make sense with refspecs"));
13691369
(void) for_each_remote(get_one_remote_for_fetch, &list);
1370-
result = fetch_multiple(&list);
13711370
} else if (argc == 0) {
13721371
/* No arguments -- use default remote */
13731372
remote = remote_get(NULL);
1374-
result = fetch_one(remote, argc, argv);
13751373
} else if (multiple) {
13761374
/* All arguments are assumed to be remotes or groups */
13771375
for (i = 0; i < argc; i++)
13781376
if (!add_remote_or_group(argv[i], &list))
13791377
die(_("No such remote or remote group: %s"), argv[i]);
1380-
result = fetch_multiple(&list);
13811378
} else {
13821379
/* Single remote or group */
13831380
(void) add_remote_or_group(argv[0], &list);
13841381
if (list.nr > 1) {
13851382
/* More than one remote */
13861383
if (argc > 1)
13871384
die(_("Fetching a group and specifying refspecs does not make sense"));
1388-
result = fetch_multiple(&list);
13891385
} else {
13901386
/* Zero or one remotes */
13911387
remote = remote_get(argv[0]);
1392-
result = fetch_one(remote, argc-1, argv+1);
1388+
argc--;
1389+
argv++;
13931390
}
13941391
}
13951392

1393+
if (remote)
1394+
result = fetch_one(remote, argc, argv);
1395+
else
1396+
result = fetch_multiple(&list);
1397+
13961398
if (!result && (recurse_submodules != RECURSE_SUBMODULES_OFF)) {
13971399
struct argv_array options = ARGV_ARRAY_INIT;
13981400

0 commit comments

Comments
 (0)