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

[PATCH 1/2] Move setup_reference to after writing the config file

From
Sverre Rabbelier <srabbelier@gmail.com>
Date
Mar 21, 2010, 20:19 UTC
Message-ID
<1269202789-8833-1-git-send-email-srabbelier@gmail.com>

Currently 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. ---

  It is also possible to split setup_reference so that the part that
  calls remote_get is where the entire setup_referene call is moved
  to now, this also works, and results in a far simpler patch.
  This change is required for the next patch.
 builtin/clone.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 05f8fb4..f878563 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);
 
-- 
1.7.0.2.325.g634e5
Next: Sverre Rabbelier
Message 1 of 3 in “Move setup_reference to after writing the config file”
  1. 1/2 Move setup_reference to after writing the config fileSverre Rabbelier, Mar 21, 2010
  2. 2/2 clone: pass the remote name to remote_getSverre Rabbelier, Mar 21, 2010
  3. Sverre RabbelierMar 21, 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.