Skip to content

Commit cd3f9be

Browse files
authored
git-completions: add correct completion for git checkout -b and git switch -c (#1219)
1 parent e95f358 commit cd3f9be

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

custom-completions/git/git-completions.nu

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ def "nu-complete git checkout" [context: string, position?:int] {
178178
}
179179
# Already typed first argument.
180180
if ($prev_tokens | length) > 2 and $preceding ends-with ' ' {
181-
return (get-checkoutable-files)
181+
# If we are creating a new branch, we may want to specify a start point
182+
if ("-b" not-in $prev_tokens) and ("-B" not-in $prev_tokens) and ("--orphan" not-in $prev_tokens) {
183+
return (get-checkoutable-files)
184+
}
182185
}
183186
# The first argument can be local branches, remote branches, files and commits
184187
# Get local and remote branches
@@ -502,6 +505,7 @@ export extern "git pull" [
502505
# Switch between branches and commits
503506
export extern "git switch" [
504507
switch?: string@"nu-complete git switch" # name of branch to switch to
508+
start_point?: string@"nu-complete git rebase" # name of the start point
505509
--create(-c) # create a new branch
506510
--detach(-d): string@"nu-complete git log" # switch to a commit in a detached state
507511
--force-create(-C): string # forces creation of new branch, if it exists then the existing branch will be reset to starting point

0 commit comments

Comments
 (0)