File tree Expand file tree Collapse file tree
home/.config/fish/functions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11function remove_worktree --description " Remove a git worktree and its backup directory"
2- set -l options h/help r/repo=
2+ set -l options h/help
33 if not argparse $options -- $argv
44 return 1
55 end
66
77 if test (count $argv ) -eq 0
8- echo " Usage: remove_worktree [--repo|-r <path>] < worktree-name>"
8+ echo " Usage: remove_worktree < worktree-name-or-path >"
99 echo " Example: remove_worktree myrepo-feature-branch"
10- echo " remove_worktree --repo ~/git/work/myrepo myrepo-feature-branch"
10+ echo " remove_worktree ~/git/worktrees/ myrepo-feature-branch"
1111 return 1
1212 end
1313
14- if set -q _flag_repo
15- set repo_root (git -C " $_ flag_repo " rev-parse --show-toplevel 2> /dev/null)
14+ if test -d " $argv [1] "
15+ set repo_root (git -C " $argv [1] " rev-parse --show-toplevel 2> /dev/null)
1616 or begin
17- echo " Error: Not a git repository : $_ flag_repo "
17+ echo " Error: Not a git worktree : $argv [1] "
1818 return 1
1919 end
20+ set worktree_name (basename " $argv [1]" )
2021 else
2122 set repo_root (git rev-parse --show-toplevel 2> /dev/null)
2223 or begin
2324 echo " Error: Not in a git repository"
2425 return 1
2526 end
27+ set worktree_name $argv [1]
2628 end
27-
28- set worktree_name $argv [1]
2929 set target_worktree " "
3030 set main_worktree " "
3131
You can’t perform that action at this time.
0 commit comments