@matheusbsbs / matheus-bagliano / commits / 766ac6a6ba
Fork 0

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 <gitster@pobox.com>

Sverre Rabbelier committed Mar 29, 2010 at 11:48 UTC 766ac6a6ba26b0d58c75234bb3553178eafa80b0
1 file changed +4 -4
builtin/clone.c
+4 -4
@@ -470,9 +470,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
470 */
471 unsetenv(CONFIG_ENVIRONMENT);
472
473 - if (option_reference)
474 - setup_reference(git_dir);
475 -
473 git_config(git_default_config, NULL);
474
475 if (option_bare) {
@@ -504,6 +501,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
501 strbuf_reset(&key);
502 }
503
504 + if (option_reference)
505 + setup_reference(git_dir);
506 +
507 fetch_pattern = value.buf;
508 refspec = parse_fetch_refspec(1, &fetch_pattern);
509
@@ -513,7 +513,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
513 refs = clone_local(path, git_dir);
514 mapped_refs = wanted_peer_refs(refs, refspec);
515 } else {
516 - struct remote *remote = remote_get(argv[0]);
516 + struct remote *remote = remote_get(option_origin);
517 transport = transport_get(remote, remote->url[0]);
518
519 if (!transport->get_refs_list || !transport->fetch)