When calling git-checkout-worktree from inside a temporary working tree
(doesn't necessary need to be a recursive call, could be another shell
too) the name would be very long.
Fix this by using the folder name of the main working tree.
Pass all given arguments to `git worktree add`. This makes it possible
to directly create a new branch with `-b` for example. As the arguments
are not used anywhere else, this should not introduce any parsing
issues.
Wrap lines at 80 columns where appropriate and I had the energy to think
about how/where to wrap.
There are still lines longer than that, which I plan to wrap in the
future. But that is enough for now.
Escape slashes in the branch name before passing it to `mktemp`.
Otherwise it would complain with:
mktemp: invalid suffix [...], contains directory separator
Add description in one sentence and use cases for this.
Remove sentence about removing `TEMP_DIR` that is outdated since:
5a8b5ffd21 ("git:checkout-worktree: Use `mktemp` template")
Use a template that directly includes the repository name and the branch
checked out. This makes finding and deleting the worktree directory if
anything goes wrong a lot easier.
Checkout the worktree directly in the temporary directory. With that
`TEMP_DIR` becomes obsolete.
Fix the exit condition when the function is called outside of a git
repository.
Use zsh's `:t` History Expansion Modifier, as `$?` does not keep `git
rev-parse`'s exit code, but rather `basename`'s.