Skip to content

Commit 502b7b6

Browse files
newrengitster
authored andcommitted
completion: fix logic for determining whether cone mode is active
_git_sparse_checkout() was checking whether we were in cone mode by checking whether either: A) core.sparseCheckoutCone was "true" B) "--cone" was specified on the command line This code has 2 bugs I didn't catch in my review at the time 1) core.sparseCheckout must be "true" for core.sparseCheckoutCone to be relevant (which matters since "git sparse-checkout disable" only unsets core.sparseCheckout, not core.sparseCheckoutCone) 2) The presence of "--no-cone" should override any config setting Further, I forgot to update this logic as part of 2d95707 ("sparse-checkout: make --cone the default", 2022-04-22) for the new default. Update the code for the new default and make it be more careful in determining whether to complete based on cone mode or non-cone mode. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebd8809 commit 502b7b6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

contrib/completion/git-completion.bash

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,6 +3097,7 @@ _git_sparse_checkout ()
30973097
{
30983098
local subcommands="list init set disable add reapply"
30993099
local subcommand="$(__git_find_on_cmdline "$subcommands")"
3100+
local using_cone=true
31003101
if [ -z "$subcommand" ]; then
31013102
__gitcomp "$subcommands"
31023103
return
@@ -3107,8 +3108,15 @@ _git_sparse_checkout ()
31073108
__gitcomp_builtin sparse-checkout_$subcommand "" "--"
31083109
;;
31093110
set,*|add,*)
3110-
if [ "$(__git config core.sparseCheckoutCone)" == "true" ] ||
3111-
[ -n "$(__git_find_on_cmdline --cone)" ]; then
3111+
if [[ "$(__git config core.sparseCheckout)" == "true" &&
3112+
"$(__git config core.sparseCheckoutCone)" == "false" &&
3113+
-z "$(__git_find_on_cmdline --cone)" ]]; then
3114+
using_cone=false
3115+
fi
3116+
if [[ -n "$(__git_find_on_cmdline --no-cone)" ]]; then
3117+
using_cone=false
3118+
fi
3119+
if [[ "$using_cone" == "true" ]]; then
31123120
__gitcomp_directories
31133121
fi
31143122
esac

0 commit comments

Comments
 (0)