From 766ac6a6ba26b0d58c75234bb3553178eafa80b0 Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Mon, 29 Mar 2010 11:48:23 -0500 Subject: clone: pass the remote name to remote_get 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. Signed-off-by: Junio C Hamano --- builtin/clone.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'builtin') diff --git a/builtin/clone.c b/builtin/clone.c index 05f8fb477..068d61fd3 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) -- cgit v1.2.1 From df61c8897950759bfe93c2b9d828487bcc7fbb6b Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Mon, 29 Mar 2010 11:48:24 -0500 Subject: clone: also configure url for bare clones Without this the 'origin' remote would not be configured, so when calling remote_get with 'origin' as argument we would get an unconfigured remote. Signed-off-by: Junio C Hamano --- builtin/clone.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'builtin') diff --git a/builtin/clone.c b/builtin/clone.c index 068d61fd3..05be999bd 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -495,12 +495,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix) git_config_set(key.buf, "true"); strbuf_reset(&key); } - - strbuf_addf(&key, "remote.%s.url", option_origin); - git_config_set(key.buf, repo); - strbuf_reset(&key); } + strbuf_addf(&key, "remote.%s.url", option_origin); + git_config_set(key.buf, repo); + strbuf_reset(&key); + if (option_reference) setup_reference(git_dir); -- cgit v1.2.1