{"thread":{"id":"18163","subject":"[PATCH 1/5] Make clone parse the default refspec with the normal code","startedAt":"2009-03-06T04:56:16Z","lastAt":"2009-03-06T04:56:16Z","messageCount":1,"participants":["Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"107141","messageId":"alpine.LNX.1.00.0903052353210.19665@iabervon.org","threadId":"18163","inReplyTo":null,"subject":"[PATCH 1/5] Make clone parse the default refspec with the normal code","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-03-06T04:56:16Z","receivedAt":"2009-03-06T04:56:16Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Instead of creating a refspec by hand, go through the refspec parsing\ncode, so that changes in the refspec storage will be accounted for.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n builtin-clone.c |   25 +++++++++++++------------\n 1 files changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex c338910..06b5a7f 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -378,7 +378,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tstruct transport *transport = NULL;\n \tchar *src_ref_prefix = \"refs/heads/\";\n \n-\tstruct refspec refspec;\n+\tstruct refspec *refspec;\n+\tconst char *fetch_pattern;\n \n \tjunk_pid = getpid();\n \n@@ -487,8 +488,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\tstrbuf_addf(&branch_top, \"refs/remotes/%s/\", option_origin);\n \t}\n \n+\tstrbuf_addf(&value, \"+%s*:%s*\", src_ref_prefix, branch_top.buf);\n+\n \tif (option_mirror || !option_bare) {\n \t\t/* Configure the remote */\n+\t\tstrbuf_addf(&key, \"remote.%s.fetch\", option_origin);\n+\t\tgit_config_set_multivar(key.buf, value.buf, \"^$\", 0);\n+\t\tstrbuf_reset(&key);\n+\n \t\tif (option_mirror) {\n \t\t\tstrbuf_addf(&key, \"remote.%s.mirror\", option_origin);\n \t\t\tgit_config_set(key.buf, \"true\");\n@@ -497,19 +504,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \n \t\tstrbuf_addf(&key, \"remote.%s.url\", option_origin);\n \t\tgit_config_set(key.buf, repo);\n-\t\t\tstrbuf_reset(&key);\n-\n-\t\tstrbuf_addf(&key, \"remote.%s.fetch\", option_origin);\n-\t\tstrbuf_addf(&value, \"+%s*:%s*\", src_ref_prefix, branch_top.buf);\n-\t\tgit_config_set_multivar(key.buf, value.buf, \"^$\", 0);\n \t\tstrbuf_reset(&key);\n-\t\tstrbuf_reset(&value);\n \t}\n \n-\trefspec.force = 0;\n-\trefspec.pattern = 1;\n-\trefspec.src = src_ref_prefix;\n-\trefspec.dst = branch_top.buf;\n+\tfetch_pattern = value.buf;\n+\trefspec = parse_fetch_refspec(1, &fetch_pattern);\n+\n+\tstrbuf_reset(&value);\n \n \tif (path && !is_bundle)\n \t\trefs = clone_local(path, git_dir);\n@@ -543,7 +544,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tif (refs) {\n \t\tclear_extra_refs();\n \n-\t\tmapped_refs = write_remote_refs(refs, &refspec, reflog_msg.buf);\n+\t\tmapped_refs = write_remote_refs(refs, refspec, reflog_msg.buf);\n \n \t\thead_points_at = locate_head(refs, mapped_refs, &remote_head);\n \t}\n-- \n1.6.1.286.gd33a4.dirty\n"}]}