diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-02-11 22:42:27 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-02-12 22:37:35 -0800 |
commit | 5cd12b85fe8ff74f202a158511ead34e8aba584c (patch) | |
tree | c77b7ebd854dc584810b85126c1c7e7fe6031172 /builtin-clone.c | |
parent | 1a526d483865d85aca3a10c650e85c44ad1f001b (diff) | |
download | git-5cd12b85fe8ff74f202a158511ead34e8aba584c.tar.gz |
Install the default "master" branch configuration after cloning a void
After "cloning from an empty repository", we have a configuration to
describe the remote's URL and the default ref mappings, but we lack the
branch configuration for the default branch we create on our end,
"master".
It is likely that the empty repository we cloned from will point the
default "master" branch with its HEAD, so prepare the local configuration
to match.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-clone.c')
-rw-r--r-- | builtin-clone.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/builtin-clone.c b/builtin-clone.c index f73029e2ba..c338910b1c 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -350,6 +350,19 @@ static struct ref *write_remote_refs(const struct ref *refs, return local_refs; } +static void install_branch_config(const char *local, + const char *origin, + const char *remote) +{ + struct strbuf key = STRBUF_INIT; + strbuf_addf(&key, "branch.%s.remote", local); + git_config_set(key.buf, origin); + strbuf_reset(&key); + strbuf_addf(&key, "branch.%s.merge", local); + git_config_set(key.buf, remote); + strbuf_release(&key); +} + int cmd_clone(int argc, const char **argv, const char *prefix) { int use_local_hardlinks = 1; @@ -539,6 +552,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix) head_points_at = NULL; remote_head = NULL; option_no_checkout = 1; + if (!option_bare) + install_branch_config("master", option_origin, + "refs/heads/master"); } if (head_points_at) { @@ -567,11 +583,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) head_points_at->peer_ref->name, reflog_msg.buf); - strbuf_addf(&key, "branch.%s.remote", head); - git_config_set(key.buf, option_origin); - strbuf_reset(&key); - strbuf_addf(&key, "branch.%s.merge", head); - git_config_set(key.buf, head_points_at->name); + install_branch_config(head, option_origin, + head_points_at->name); } } else if (remote_head) { /* Source had detached HEAD pointing somewhere. */ |