diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-03-20 14:30:00 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-20 14:30:00 -0700 |
commit | 8e50ada5530c6bc937c5a7c10130b2b09f1389f2 (patch) | |
tree | 09d3b7d36847ec819a261d7a285032679617e9b1 /builtin-clone.c | |
parent | Merge branch 'jc/clone-branch-rebase' (diff) | |
parent | Adjust js/remote-improvements and db/refspec-wildcard-in-the-middle (diff) | |
download | tgif-8e50ada5530c6bc937c5a7c10130b2b09f1389f2.tar.xz |
Merge branch 'xx/db-refspec-vs-js-remote'
* xx/db-refspec-vs-js-remote:
Support '*' in the middle of a refspec
Keep '*' in pattern refspecs
Use the matching function to generate the match results
Use a single function to match names against patterns
Make clone parse the default refspec with the normal code
Diffstat (limited to 'builtin-clone.c')
-rw-r--r-- | builtin-clone.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/builtin-clone.c b/builtin-clone.c index 7fbfbf973c..0031b5f51c 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -330,7 +330,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) char *src_ref_prefix = "refs/heads/"; int err = 0; - struct refspec refspec; + struct refspec *refspec; + const char *fetch_pattern; junk_pid = getpid(); @@ -435,8 +436,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"); @@ -445,19 +452,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); @@ -491,7 +492,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); remote_head = find_ref_by_name(refs, "HEAD"); head_points_at = guess_remote_head(remote_head, mapped_refs, 0); |