diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2015-07-17 19:00:03 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-07-20 11:29:24 -0700 |
commit | 746bbdc64f1e1b2618cd71e5da81e38aa772e8ba (patch) | |
tree | 0dcdbcb719ba305fdaaca9aa6a844380a2370def /builtin/checkout.c | |
parent | 33aef83666900df03c39bcf7e391e2f8195dd13c (diff) | |
download | git-746bbdc64f1e1b2618cd71e5da81e38aa772e8ba.tar.gz |
checkout: teach check_linked_checkout() about symbolic link HEAD
check_linked_checkout() only understands symref-style HEAD (i.e. "ref:
refs/heads/master"), however, HEAD may also be a an actual symbolic link
(on platforms which support it). To accurately detect if a branch is
checked out elsewhere, it needs to handle symbolic link HEAD, as well.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r-- | builtin/checkout.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index 6f4e49232a..f04dcaaf1f 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -889,7 +889,11 @@ static void check_linked_checkout(const char *branch, const char *id) else strbuf_addf(&path, "%s/HEAD", get_git_common_dir()); - if (strbuf_read_file(&sb, path.buf, 0) >= 0 && + if (!strbuf_readlink(&sb, path.buf, 0)) { + if (!starts_with(sb.buf, "refs/") || + check_refname_format(sb.buf, 0)) + goto done; + } else if (strbuf_read_file(&sb, path.buf, 0) >= 0 && starts_with(sb.buf, "ref:")) { strbuf_remove(&sb, 0, strlen("ref:")); strbuf_trim(&sb); |