mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-13 08:46:17 -04:00
checkout_branch: support "-" argument
git natively supports `-` as an argument to `git switch` and `git
checkout`. It is shorthand for `@{-1}`, which is a way to refer to the
last branch you were on.
forgit used to interpret `-` as a branch name, detect that it does not
exist yet and create a new one with this name, which does not work.
Add a check whether `-` is passed on the command line and do not create
a new branch in this case
This commit is contained in:
parent
b663d22f5b
commit
432b642a16
|
|
@ -454,7 +454,7 @@ _forgit_checkout_branch() {
|
|||
_forgit_inside_work_tree || return 1
|
||||
# if called with arguments, check if branch exists, else create a new one
|
||||
if [[ $# -ne 0 ]]; then
|
||||
if git show-branch "$@" &>/dev/null; then
|
||||
if [[ "$*" == "-" ]] || git show-branch "$@" &>/dev/null; then
|
||||
git switch "$@"
|
||||
else
|
||||
git switch -c "$@"
|
||||
|
|
|
|||
Loading…
Reference in a new issue