checkout: refactor die_if_checked_out() caller
commit9263c40a0a0c299db59b8a64e87b95026a28812a
authorJunio C Hamano <gitster@pobox.com>
Thu, 23 Nov 2023 05:11:41 +0000 (23 14:11 +0900)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Nov 2023 06:01:09 +0000 (23 15:01 +0900)
tree2008dadc40e03300ed8e7985c3ffda5f9104d661
parent564d0252ca632e0264ed670534a51d18a689ef5d
checkout: refactor die_if_checked_out() caller

There is a bit dense logic to make a call to "die_if_checked_out()"
while trying to check out a branch.  Extract it into a helper
function and give it a bit of comment to describe what is going on.

The most important part of the refactoring is the separation of the
guarding logic before making the call to die_if_checked_out() into
the caller specific part (e.g., the logic that decides that the
caller is trying to check out an existing branch) and the bypass due
to the "--ignore-other-worktrees" option.  The latter will be common
no matter how the current or future callers decides they need this
protection.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c