Skip to content

Commit c5a7ee1

Browse files
committed
Merge branch 'rj/complete-worktree-paths-fix'
The logic to complete the command line arguments to "git worktree" subcommand (in contrib/) has been updated to correctly honor things like "git -C dir" etc. * rj/complete-worktree-paths-fix: completion: fix __git_complete_worktree_paths
2 parents 4310074 + 3574816 commit c5a7ee1

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3629,7 +3629,7 @@ __git_complete_worktree_paths ()
36293629
# Generate completion reply from worktree list skipping the first
36303630
# entry: it's the path of the main worktree, which can't be moved,
36313631
# removed, locked, etc.
3632-
__gitcomp_nl "$(git worktree list --porcelain |
3632+
__gitcomp_nl "$(__git worktree list --porcelain |
36333633
sed -n -e '2,$ s/^worktree //p')"
36343634
}
36353635

t/t9902-completion.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,29 @@ test_expect_success '__git_complete_fetch_refspecs - fully qualified & prefix' '
12631263
test_cmp expected out
12641264
'
12651265

1266+
test_expect_success '__git_complete_worktree_paths' '
1267+
test_when_finished "git worktree remove other_wt" &&
1268+
git worktree add --orphan other_wt &&
1269+
run_completion "git worktree remove " &&
1270+
grep other_wt out
1271+
'
1272+
1273+
test_expect_success '__git_complete_worktree_paths - not a git repository' '
1274+
(
1275+
cd non-repo &&
1276+
GIT_CEILING_DIRECTORIES="$ROOT" &&
1277+
export GIT_CEILING_DIRECTORIES &&
1278+
test_completion "git worktree remove " ""
1279+
)
1280+
'
1281+
1282+
test_expect_success '__git_complete_worktree_paths with -C' '
1283+
test_when_finished "git -C otherrepo worktree remove otherrepo_wt" &&
1284+
git -C otherrepo worktree add --orphan otherrepo_wt &&
1285+
run_completion "git -C otherrepo worktree remove " &&
1286+
grep otherrepo_wt out
1287+
'
1288+
12661289
test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' '
12671290
test_completion "git switch " <<-\EOF
12681291
branch-in-other Z

0 commit comments

Comments
 (0)