git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v7 08/16] fetch: refactor calculation of remote list

From
JHJeff Hostetler <git@jeffhostetler.com>
Date
Dec 8, 2017, 15:58 UTC
Message-ID
<20171208155851.855-9-git@jeffhostetler.com>
In-Reply-To
<20171208155851.855-1-git@jeffhostetler.com>
From: Jonathan Tan <jonathantanmy@google.com>

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 <jonathantanmy@google.com>
---
 builtin/fetch.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 225c734..1b1f039 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1322,7 +1322,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 {
 	int i;
 	struct string_list list = STRING_LIST_INIT_DUP;
-	struct remote *remote;
+	struct remote *remote = NULL;
 	int result = 0;
 	struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
 
@@ -1367,17 +1367,14 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 		else if (argc > 1)
 			die(_("fetch --all does not make sense with refspecs"));
 		(void) for_each_remote(get_one_remote_for_fetch, &list);
-		result = fetch_multiple(&list);
 	} else if (argc == 0) {
 		/* No arguments -- use default remote */
 		remote = remote_get(NULL);
-		result = fetch_one(remote, argc, argv);
 	} else if (multiple) {
 		/* All arguments are assumed to be remotes or groups */
 		for (i = 0; i < argc; i++)
 			if (!add_remote_or_group(argv[i], &list))
 				die(_("No such remote or remote group: %s"), argv[i]);
-		result = fetch_multiple(&list);
 	} else {
 		/* Single remote or group */
 		(void) add_remote_or_group(argv[0], &list);
@@ -1385,14 +1382,19 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 			/* More than one remote */
 			if (argc > 1)
 				die(_("Fetching a group and specifying refspecs does not make sense"));
-			result = fetch_multiple(&list);
 		} else {
 			/* Zero or one remotes */
 			remote = remote_get(argv[0]);
-			result = fetch_one(remote, argc-1, argv+1);
+			argc--;
+			argv++;
 		}
 	}
 
+	if (remote)
+		result = fetch_one(remote, argc, argv);
+	else
+		result = fetch_multiple(&list);
+
 	if (!result && (recurse_submodules != RECURSE_SUBMODULES_OFF)) {
 		struct argv_array options = ARGV_ARRAY_INIT;
 
-- 
2.9.3
Previous: Jeff HostetlerNext: Jeff Hostetler
Message 14 of 24 in “Parial clone part 3: clone, fetch, fetch-pack, upload-pack, and tests”
  1. 00/16 Parial clone part 3: clone, fetch, fetch-pack, upload-pack, and testsJeff Hostetler, Dec 8, 2017
  2. 03/16 gc: do not repack promisor packfilesJeff Hostetler, Dec 8, 2017
  3. 09/16 fetch: support filtersJeff Hostetler, Dec 8, 2017
  4. Duy NguyenAug 19, 2018
  5. Jeff HostetlerAug 20, 2018
  6. 13/16 fetch-pack: restore save_commit_buffer after useJeff Hostetler, Dec 8, 2017
  7. 12/16 unpack-trees: batch fetching of missing blobsJeff Hostetler, Dec 8, 2017
  8. 11/16 clone: partial cloneJeff Hostetler, Dec 8, 2017
  9. 15/16 fetch: inherit filter-spec from partial cloneJeff Hostetler, Dec 8, 2017
  10. 16/16 t5616: test bulk prefetch after partial fetchJeff Hostetler, Dec 8, 2017
  11. 10/16 partial-clone: define partial clone settings in configJeff Hostetler, Dec 8, 2017
  12. 14/16 t5616: end-to-end tests for partial cloneJeff Hostetler, Dec 8, 2017
  13. 02/16 rev-list: support termination at promisor objectsJeff Hostetler, Dec 8, 2017
  14. 08/16 fetch: refactor calculation of remote listJeff Hostetler, Dec 8, 2017
  15. 07/16 fetch-pack: test support excluding large blobsJeff Hostetler, Dec 8, 2017
  16. 01/16 sha1_file: support lazily fetching missing objectsJeff Hostetler, Dec 8, 2017
  17. 05/16 fetch-pack, index-pack, transport: partial cloneJeff Hostetler, Dec 8, 2017
  18. 06/16 fetch-pack: add --no-filterJeff Hostetler, Dec 8, 2017
  19. 04/16 upload-pack: add object filtering for partial cloneJeff Hostetler, Dec 8, 2017
  20. Junio C HamanoDec 8, 2017
  21. Jeff HostetlerDec 8, 2017
  22. Junio C HamanoDec 8, 2017
  23. Brandon WilliamsDec 8, 2017
  24. Jonathan TanDec 11, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.