From: Junio C Hamano Date: Thu, 5 Jul 2012 06:41:41 +0000 (-0700) Subject: Merge branch 'nd/clone-single-fix' X-Git-Tag: v1.7.12-rc0~61 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/57c054c5d0e72d5665322a4bebb7f380390edde5?ds=inline;hp=-c Merge branch 'nd/clone-single-fix' "git clone --single-branch" to clone a single branch did not limit the cloning to the specified branch. * nd/clone-single-fix: clone: fix ref selection in --single-branch --branch=xxx --- 57c054c5d0e72d5665322a4bebb7f380390edde5 diff --combined builtin/clone.c index 7f3b9823ce,f86aaf18f7..d3b7fdccec --- a/builtin/clone.c +++ b/builtin/clone.c @@@ -38,7 -38,7 +38,7 @@@ static const char * const builtin_clone }; static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1; -static int option_local, option_no_hardlinks, option_shared, option_recursive; +static int option_local = -1, option_no_hardlinks, option_shared, option_recursive; static char *option_template, *option_depth; static char *option_origin = NULL; static char *option_branch = NULL; @@@ -70,8 -70,8 +70,8 @@@ static struct option builtin_clone_opti PARSE_OPT_NOARG | PARSE_OPT_HIDDEN }, OPT_BOOLEAN(0, "mirror", &option_mirror, "create a mirror repository (implies bare)"), - OPT_BOOLEAN('l', "local", &option_local, - "to clone from a local repository"), + OPT_BOOL('l', "local", &option_local, + "to clone from a local repository"), OPT_BOOLEAN(0, "no-hardlinks", &option_no_hardlinks, "don't use local hardlinks, always copy"), OPT_BOOLEAN('s', "shared", &option_shared, @@@ -342,7 -342,7 +342,7 @@@ static void copy_or_link_directory(stru if (!option_no_hardlinks) { if (!link(src->buf, dest->buf)) continue; - if (option_local) + if (option_local > 0) die_errno(_("failed to create link '%s'"), dest->buf); option_no_hardlinks = 1; } @@@ -433,8 -433,11 +433,11 @@@ static struct ref *wanted_peer_refs(con if (!option_branch) remote_head = guess_remote_head(head, refs, 0); - else - remote_head = find_remote_branch(refs, option_branch); + else { + local_refs = NULL; + tail = &local_refs; + remote_head = copy_ref(find_remote_branch(refs, option_branch)); + } if (!remote_head && option_branch) warning(_("Could not find remote branch %s to clone."), @@@ -668,7 -671,7 +671,7 @@@ int cmd_clone(int argc, const char **ar die(_("repository '%s' does not exist"), repo_name); else repo = repo_name; - is_local = path && !is_bundle; + is_local = option_local != 0 && path && !is_bundle; if (is_local && option_depth) warning(_("--depth is ignored in local clones; use file:// instead."));