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

[PATCH 1/7] clone: pass the remote name to remote_get

From
Sverre Rabbelier <srabbelier@gmail.com>
Date
Mar 29, 2010, 16:48 UTC
Message-ID
<1269881309-19690-2-git-send-email-srabbelier@gmail.com>
In-Reply-To
<1269881309-19690-1-git-send-email-srabbelier@gmail.com>

Currently when using a remote helper to clone a repository, the remote helper will be passed the url of the target repository as first argument (which represents the name of the remote). This name is extracted from transport->remote->name, which is set by builtin/clone.c when it calls remote_get with argv[0] as argument.

Fix this by passing the name remote will be set up as instead.

However, setup_reference calls remote_get before the remote is added to the config file. This will result in an improperly configured remote (in memory) if later on remote_get is called with an argument that is not equal to the initial remote_get call in setup_reference. Fix this by delaying the remote_get call until after the remote has been added to the config file. ---

	This is a combination of the earlier two-patch fix I sent.
 builtin/clone.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 05f8fb4..068d61f 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -470,9 +470,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	 */
 	unsetenv(CONFIG_ENVIRONMENT);
 
-	if (option_reference)
-		setup_reference(git_dir);
-
 	git_config(git_default_config, NULL);
 
 	if (option_bare) {
@@ -504,6 +501,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		strbuf_reset(&key);
 	}
 
+	if (option_reference)
+		setup_reference(git_dir);
+
 	fetch_pattern = value.buf;
 	refspec = parse_fetch_refspec(1, &fetch_pattern);
 
@@ -513,7 +513,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		refs = clone_local(path, git_dir);
 		mapped_refs = wanted_peer_refs(refs, refspec);
 	} else {
-		struct remote *remote = remote_get(argv[0]);
+		struct remote *remote = remote_get(option_origin);
 		transport = transport_get(remote, remote->url[0]);
 
 		if (!transport->get_refs_list || !transport->fetch)
-- 
1.7.0.3.317.gbb04ec
Previous: Sverre RabbelierNext: Sverre Rabbelier
Message 2 of 14 in “remote-helpers: exporting”
  1. 0/7 remote-helpers: exportingSverre Rabbelier, Mar 29, 2010
  2. 1/7 clone: pass the remote name to remote_getSverre Rabbelier, Mar 29, 2010
  3. 2/7 clone: also configure url for bare clonesSverre Rabbelier, Mar 29, 2010
  4. 3/7 fast-import: always create marks_file directoriesSverre Rabbelier, Mar 29, 2010
  5. 4/7 remote-helpers: allow requesing the path to the .git directorySverre Rabbelier, Mar 29, 2010
  6. 5/7 remote-helpers: add support for an export commandSverre Rabbelier, Mar 29, 2010
  7. Daniel BarkalowMar 29, 2010
  8. Sverre RabbelierMar 29, 2010
  9. Junio C HamanoApr 1, 2010
  10. Sverre RabbelierApr 1, 2010
  11. 6/7 remote-helpers: add testgit helperSverre Rabbelier, Mar 29, 2010
  12. 7/7 remote-helpers: add tests for testgit helperSverre Rabbelier, Mar 29, 2010
  13. Jonathan NiederApr 12, 2010
  14. Sverre RabbelierApr 12, 2010

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.