branch: check for bisects and rebases
commitd2ba271aad0e7f90b475be6225c59cb4f1bfbe4f
authorDerrick Stolee <derrickstolee@github.com>
Tue, 14 Jun 2022 19:27:30 +0000 (14 19:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Jun 2022 17:47:18 +0000 (15 10:47 -0700)
tree5ffcd49e19a9921317f44ca04a591324a3ba71be
parent31ad6b61bdaa408f2616d7dca0f6d66ee4742c8d
branch: check for bisects and rebases

The branch_checked_out() helper was added by the previous change, but it
used an over-simplified view to check if a branch is checked out. It
only focused on the HEAD symref, but ignored whether a bisect or rebase
was happening.

Teach branch_checked_out() to check for these things, and also add tests
to ensure that we do not lose this functionality in the future.

Now that this test coverage exists, we can safely refactor
validate_new_branchname() to use branch_checked_out().

Note that we need to prepend "refs/heads/" to the 'state.branch' after
calling wt_status_check_*(). We also need to duplicate wt->path so the
value is not freed at the end of the call.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c
t/t2407-worktree-heads.sh