Skip to content

Commit e9f2118

Browse files
felipecgitster
authored andcommitted
completion: bash: fix for suboptions with value
We need to ignore options that don't start with -- as well. Depending on the value of COMP_WORDBREAKS the last word could be duplicated otherwise. Can be tested with: git merge -X diff-algorithm=<tab> Tested-by: David Aguilar <[email protected]> Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bf8ae49 commit e9f2118

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ __gitcomp ()
356356
local cur_="${3-$cur}"
357357

358358
case "$cur_" in
359-
--*=)
359+
*=)
360360
;;
361361
--no-*)
362362
local c i=0 IFS=$' \t\n'

t/t9902-completion.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,15 @@ test_expect_success '__gitcomp - expand/narrow all negative options' '
540540
EOF
541541
'
542542

543+
test_expect_success '__gitcomp - equal skip' '
544+
test_gitcomp "--option=" "--option=" <<-\EOF &&
545+
546+
EOF
547+
test_gitcomp "option=" "option=" <<-\EOF
548+
549+
EOF
550+
'
551+
543552
test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '
544553
__gitcomp "$invalid_variable_name"
545554
'
@@ -2380,6 +2389,12 @@ test_expect_success 'git clone --config= - value' '
23802389
EOF
23812390
'
23822391

2392+
test_expect_success 'options with value' '
2393+
test_completion "git merge -X diff-algorithm=" <<-\EOF
2394+
2395+
EOF
2396+
'
2397+
23832398
test_expect_success 'sourcing the completion script clears cached commands' '
23842399
__git_compute_all_commands &&
23852400
verbose test -n "$__git_all_commands" &&

0 commit comments

Comments
 (0)