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>
Daniel Barkalow committed
Mar 5, 2009 at 23:56 UTC
689f03964360114bc1139d82b1f6a0d7b897bbf0
1 file changed
+13
-12
builtin-clone.c
+13
-12
@@ -378,7 +378,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
378
struct transport *transport = NULL;
379
char *src_ref_prefix = "refs/heads/";
380
381
- struct refspec refspec;
381
+ struct refspec *refspec;
382
+ const char *fetch_pattern;
383
384
junk_pid = getpid();
385
@@ -487,8 +488,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
488
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
489
}
490
491
+ strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
492
+
493
if (option_mirror || !option_bare) {
494
/* Configure the remote */
495
+ strbuf_addf(&key, "remote.%s.fetch", option_origin);
496
+ git_config_set_multivar(key.buf, value.buf, "^$", 0);
497
+ strbuf_reset(&key);
498
+
499
if (option_mirror) {
500
strbuf_addf(&key, "remote.%s.mirror", option_origin);
501
git_config_set(key.buf, "true");
@@ -497,19 +504,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
504
505
strbuf_addf(&key, "remote.%s.url", option_origin);
506
git_config_set(key.buf, repo);
500
- strbuf_reset(&key);
501
-
502
- strbuf_addf(&key, "remote.%s.fetch", option_origin);
503
- strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
504
- git_config_set_multivar(key.buf, value.buf, "^$", 0);
507
strbuf_reset(&key);
506
- strbuf_reset(&value);
508
}
509
509
- refspec.force = 0;
510
- refspec.pattern = 1;
511
- refspec.src = src_ref_prefix;
512
- refspec.dst = branch_top.buf;
510
+ fetch_pattern = value.buf;
511
+ refspec = parse_fetch_refspec(1, &fetch_pattern);
512
+
513
+ strbuf_reset(&value);
514
515
if (path && !is_bundle)
516
refs = clone_local(path, git_dir);
@@ -543,7 +544,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
544
if (refs) {
545
clear_extra_refs();
546
546
- mapped_refs = write_remote_refs(refs, &refspec, reflog_msg.buf);
547
+ mapped_refs = write_remote_refs(refs, refspec, reflog_msg.buf);
548
549
head_points_at = locate_head(refs, mapped_refs, &remote_head);
550
}