[PATCH v2 4/6] clone: --branch=<branch> always means refs/heads/<branch>
- From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
- Date
- Jan 8, 2012, 11:46 UTC
- Message-ID
- <1326023188-15559-4-git-send-email-pclouds@gmail.com>
- In-Reply-To
- <1326023188-15559-1-git-send-email-pclouds@gmail.com>
It does not make sense to look outside refs/heads for HEAD's target (src_ref_prefix can be set to "refs/" if --mirror is used) because ref code only allows symref in form refs/heads/...
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> --- builtin/clone.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c index 100056d..914fd6b 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -727,7 +727,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (option_branch) { struct strbuf head = STRBUF_INIT; - strbuf_addstr(&head, src_ref_prefix); + strbuf_addstr(&head, "refs/heads/"); strbuf_addstr(&head, option_branch); our_head_points_at = find_ref_by_name(mapped_refs, head.buf); @@ -763,7 +763,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix) reflog_msg.buf); } - if (our_head_points_at) { + if (our_head_points_at && + !prefixcmp(our_head_points_at->name, "refs/heads/")) { /* Local default branch link */ create_symref("HEAD", our_head_points_at->name, NULL); if (!option_bare) {
-- 1.7.8.36.g69ee2