worktree: detect branch-name/detached and error conditions locally
commitf7c9dac1b037e453e934c272d77cc648d56d5477
authorEric Sunshine <sunshine@sunshineco.com>
Fri, 17 Jul 2015 23:00:13 +0000 (17 19:00 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Jul 2015 18:29:52 +0000 (20 11:29 -0700)
tree9eb5bec4ee344a68f62d19039879486f8f2d01d6
parent80a0548f6c12f43e9bd62e13eacb033f05e2b001
worktree: detect branch-name/detached and error conditions locally

git-worktree currently conflates setting of HEAD in the new worktree
with initial worktree population via a single git-checkout invocation,
which requires git-checkout to have special knowledge that it is
operating in a newly created worktree. The eventual goal is to separate
these operations and rid git-checkout of that overly-intimate knowledge.

Once these operations are separate, git-worktree will no longer be able
to rely upon git-branch to determine the state of the worktree (branch
name or detached), or to check for error conditions, such as the
requested branch already checked out elsewhere, or an invalid reference.
Therefore, imbue git-worktree with the intelligence to determine a
branch name or detached state locally, and to perform error checking on
its own.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/worktree.c