summaryrefslogtreecommitdiff
path: root/builtin-clone.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2009-03-05 23:56:16 -0500
committerJunio C Hamano <gitster@pobox.com>2009-03-07 12:19:05 -0800
commit689f03964360114bc1139d82b1f6a0d7b897bbf0 (patch)
tree39cef059e3ab68acd0da96b15b26dda3fe162cc9 /builtin-clone.c
parent8cc3fe45c92a2e85400a6ee83c3b3a4a8ca1d6c7 (diff)
downloadgit-689f03964360114bc1139d82b1f6a0d7b897bbf0.tar.gz
Make clone parse the default refspec with the normal code
Instead of creating a refspec by hand, go through the refspec parsing code, so that changes in the refspec storage will be accounted for. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-clone.c')
-rw-r--r--builtin-clone.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/builtin-clone.c b/builtin-clone.c
index c338910b1c..06b5a7fc39 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -378,7 +378,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
struct transport *transport = NULL;
char *src_ref_prefix = "refs/heads/";
- struct refspec refspec;
+ struct refspec *refspec;
+ const char *fetch_pattern;
junk_pid = getpid();
@@ -487,8 +488,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
}
+ strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
+
if (option_mirror || !option_bare) {
/* Configure the remote */
+ strbuf_addf(&key, "remote.%s.fetch", option_origin);
+ git_config_set_multivar(key.buf, value.buf, "^$", 0);
+ strbuf_reset(&key);
+
if (option_mirror) {
strbuf_addf(&key, "remote.%s.mirror", option_origin);
git_config_set(key.buf, "true");
@@ -497,19 +504,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
strbuf_addf(&key, "remote.%s.url", option_origin);
git_config_set(key.buf, repo);
- strbuf_reset(&key);
-
- strbuf_addf(&key, "remote.%s.fetch", option_origin);
- strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
- git_config_set_multivar(key.buf, value.buf, "^$", 0);
strbuf_reset(&key);
- strbuf_reset(&value);
}
- refspec.force = 0;
- refspec.pattern = 1;
- refspec.src = src_ref_prefix;
- refspec.dst = branch_top.buf;
+ fetch_pattern = value.buf;
+ refspec = parse_fetch_refspec(1, &fetch_pattern);
+
+ strbuf_reset(&value);
if (path && !is_bundle)
refs = clone_local(path, git_dir);
@@ -543,7 +544,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (refs) {
clear_extra_refs();
- mapped_refs = write_remote_refs(refs, &refspec, reflog_msg.buf);
+ mapped_refs = write_remote_refs(refs, refspec, reflog_msg.buf);
head_points_at = locate_head(refs, mapped_refs, &remote_head);
}