Skip to content

Commit d95f6f0

Browse files
author
lu0
committed
Omit start point when creating new branches
1 parent ea6a234 commit d95f6f0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

libs/_checkout.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ checkout::_create_branch_and_worktree() {
5151
local opt="${2:-}" to="${3:-}" from="${4:-}"
5252
local to_dir existing_branch
5353

54-
if [ -z "${from:-}" ]; then
55-
# Use current branch as reference
56-
from=$(utils::git branch --show-current)
57-
fi
58-
5954
to_dir=$(utils::branch_to_dir_name "${to}")
6055
existing_branch=$(utils::git branch --list "${to}")
6156

@@ -67,7 +62,8 @@ checkout::_create_branch_and_worktree() {
6762
else
6863
# Create branch if does not exist
6964
if [ -z "${existing_branch:-}" ]; then
70-
utils::git branch "${to}" "${from}"
65+
# shellcheck disable=SC2086
66+
utils::git branch "${to}" ${from}
7167
fi
7268

7369
# Create worktree if does not exist
@@ -79,7 +75,8 @@ checkout::_create_branch_and_worktree() {
7975
if [ "${opt}" == "-B" ]; then
8076
# Let git handle resets. Vanilla checkouts
8177
# always trigger post-checkout hooks.
82-
utils::git checkout -B "${to}" "${from}"
78+
# shellcheck disable=SC2086
79+
utils::git checkout -B "${to}" ${from}
8380
else
8481
# Trigger post-checkout hooks
8582
checkout::__trigger_post_hook

0 commit comments

Comments
 (0)