Skip to content

Commit f70b541

Browse files
committed
Merge branch 'ab/completion-push-delete-ref'
The completion script (in contrib/) learned to complete "git push --delete b<TAB>" to complete branch name to be deleted. * ab/completion-push-delete-ref: completion: expand "push --delete <remote> <ref>" for refs on that <remote>
2 parents 3961c51 + 723c1d5 commit f70b541

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

contrib/completion/git-completion.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ __git_complete_remote_or_refspec ()
709709
i="${words[c]}"
710710
case "$i" in
711711
--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
712+
-d|--delete) [ "$cmd" = "push" ] && lhs=0 ;;
712713
--all)
713714
case "$cmd" in
714715
push) no_complete_refspec=1 ;;

t/t9902-completion.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,38 @@ test_expect_failure 'complete with tilde expansion' '
14571457
test_completion "git add ~/tmp/" "~/tmp/file"
14581458
'
14591459

1460+
test_expect_success 'setup other remote for remote reference completion' '
1461+
git remote add other otherrepo &&
1462+
git fetch other
1463+
'
1464+
1465+
for flag in -d --delete
1466+
do
1467+
test_expect_success "__git_complete_remote_or_refspec - push $flag other" '
1468+
sed -e "s/Z$//" >expected <<-EOF &&
1469+
master-in-other Z
1470+
EOF
1471+
(
1472+
words=(git push '$flag' other ma) &&
1473+
cword=${#words[@]} cur=${words[cword-1]} &&
1474+
__git_complete_remote_or_refspec &&
1475+
print_comp
1476+
) &&
1477+
test_cmp expected out
1478+
'
1479+
1480+
test_expect_failure "__git_complete_remote_or_refspec - push other $flag" '
1481+
sed -e "s/Z$//" >expected <<-EOF &&
1482+
master-in-other Z
1483+
EOF
1484+
(
1485+
words=(git push other '$flag' ma) &&
1486+
cword=${#words[@]} cur=${words[cword-1]} &&
1487+
__git_complete_remote_or_refspec &&
1488+
print_comp
1489+
) &&
1490+
test_cmp expected out
1491+
'
1492+
done
1493+
14601494
test_done

0 commit comments

Comments
 (0)