mirror of
https://github.com/git/git.git
synced 2024-11-27 12:03:55 +08:00
completion: fix __git_complete_worktree_paths
Use __git to invoke "worktree list" in __git_complete_worktree_paths, to respect any "-C" and "--git-dir" options present on the command line. Signed-off-by: Rubén Justo <rjusto@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3c2a3fdc38
commit
3574816d98
@ -3571,7 +3571,7 @@ __git_complete_worktree_paths ()
|
||||
# Generate completion reply from worktree list skipping the first
|
||||
# entry: it's the path of the main worktree, which can't be moved,
|
||||
# removed, locked, etc.
|
||||
__gitcomp_nl "$(git worktree list --porcelain |
|
||||
__gitcomp_nl "$(__git worktree list --porcelain |
|
||||
sed -n -e '2,$ s/^worktree //p')"
|
||||
}
|
||||
|
||||
|
@ -1263,6 +1263,29 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified & prefix' '
|
||||
test_cmp expected out
|
||||
'
|
||||
|
||||
test_expect_success '__git_complete_worktree_paths' '
|
||||
test_when_finished "git worktree remove other_wt" &&
|
||||
git worktree add --orphan other_wt &&
|
||||
run_completion "git worktree remove " &&
|
||||
grep other_wt out
|
||||
'
|
||||
|
||||
test_expect_success '__git_complete_worktree_paths - not a git repository' '
|
||||
(
|
||||
cd non-repo &&
|
||||
GIT_CEILING_DIRECTORIES="$ROOT" &&
|
||||
export GIT_CEILING_DIRECTORIES &&
|
||||
test_completion "git worktree remove " ""
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success '__git_complete_worktree_paths with -C' '
|
||||
test_when_finished "git -C otherrepo worktree remove otherrepo_wt" &&
|
||||
git -C otherrepo worktree add --orphan otherrepo_wt &&
|
||||
run_completion "git -C otherrepo worktree remove " &&
|
||||
grep otherrepo_wt out
|
||||
'
|
||||
|
||||
test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' '
|
||||
test_completion "git switch " <<-\EOF
|
||||
branch-in-other Z
|
||||
|
Loading…
Reference in New Issue
Block a user