From: Paolo Bonzini <bonzini@gnu.org>
To: <git@vger.kernel.org>
Subject: [PATCH RFC 5/8] clone: refactoring of building the fetch refspec
Date: Mon, 20 Jul 2009 19:49:52 +0200 [thread overview]
Message-ID: <1248112195-3761-6-git-send-email-bonzini@gnu.org> (raw)
In-Reply-To: <1248112195-3761-1-git-send-email-bonzini@gnu.org>
In builtin-clone.c, two variables (src_ref_prefix and branch_top.buf)
were used to represent basically two parts of a refspec. Since a
refspec is built anyway later, we can drop these variables and
use refspec->dst when we need it.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
---
builtin-clone.c | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index 552ddf6..345101a 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -349,9 +349,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
int dest_exists;
const struct ref *refs, *head_points_at, *remote_head, *mapped_refs;
struct strbuf key = STRBUF_INIT, value = STRBUF_INIT;
- struct strbuf branch_top = STRBUF_INIT, reflog_msg = STRBUF_INIT;
+ struct strbuf reflog_msg = STRBUF_INIT;
struct transport *transport = NULL;
- char *src_ref_prefix = "refs/heads/";
int err = 0;
struct refspec *refspec;
@@ -452,20 +451,21 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (option_bare) {
if (option_mirror)
- src_ref_prefix = "refs/";
- strbuf_addstr(&branch_top, src_ref_prefix);
+ fetch_pattern = "+refs/*:refs/*";
+ else
+ fetch_pattern = "+refs/heads/*:refs/heads/*";
git_config_set("core.bare", "true");
} else {
- strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
+ strbuf_addf(&value, "+refs/heads/*:refs/remotes/%s/*:*",
+ option_origin);
+ fetch_pattern = value.buf;
}
- 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);
+ git_config_set_multivar(key.buf, fetch_pattern, "^$", 0);
strbuf_reset(&key);
if (option_mirror) {
@@ -479,7 +479,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
strbuf_reset(&key);
}
- fetch_pattern = value.buf;
refspec = parse_fetch_refspec(1, &fetch_pattern);
strbuf_reset(&value);
@@ -549,7 +548,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
head_points_at->old_sha1,
NULL, 0, DIE_ON_ERR);
- strbuf_addstr(&head_ref, branch_top.buf);
+ strbuf_addstr(&head_ref, refspec->dst);
+ strbuf_setlen(&head_ref, head_ref.len - 1);
strbuf_addstr(&head_ref, "HEAD");
/* Remote branch link */
@@ -611,7 +611,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
}
strbuf_release(&reflog_msg);
- strbuf_release(&branch_top);
strbuf_release(&key);
strbuf_release(&value);
junk_pid = 0;
--
1.6.2.5
next prev parent reply other threads:[~2009-07-20 17:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-20 17:49 [PATCH RFC 0/8] introduce 'git remote add --push' and 'git clone --push' Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 1/8] reintroduce PUSH_DEFAULT_UNSPECIFIED Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 2/8] push: add push.default = mirror Paolo Bonzini
2009-07-20 20:46 ` Junio C Hamano
2009-07-20 21:14 ` Paolo Bonzini
2009-07-20 21:34 ` Junio C Hamano
2009-07-20 21:36 ` Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 3/8] git remote add: refactor configuration Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 4/8] git remote add: add --push option Paolo Bonzini
2009-07-20 17:49 ` Paolo Bonzini [this message]
2009-07-20 17:49 ` [PATCH RFC 6/8] clone: use setup_remote_config Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 7/8] config: add git_config_norepo Paolo Bonzini
2009-07-20 17:49 ` [PATCH RFC 8/8] clone: add --push option Paolo Bonzini
2009-07-20 22:15 ` [PATCH RFC 0/8] introduce 'git remote add --push' and 'git clone --push' Junio C Hamano
2009-07-21 10:33 ` Paolo Bonzini
2009-07-21 21:00 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1248112195-3761-6-git-send-email-bonzini@gnu.org \
--to=bonzini@gnu.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).