This revision adds missing double quotes to improve the completion situation for paths with spaces in them, and adds some comments. Britton Leo Kerin (1): completion: dir-type optargs for am, format-patch contrib/completion/git-completion.bash | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) Range-diff against v1: 1: 2d788b0b18 ! 1: 5161304a92 completion: dir-type optargs for am, format-patch @@ contrib/completion/git-completion.bash: __git_count_arguments () printf "%d" $c } -+ +# Complete actual dir (not pathspec), respecting any -C options. +# +# Usage: __git_complete_refs [<option>]... @@ contrib/completion/git-completion.bash: __git_count_arguments () + shift + done + ++ # This rev-parse invocation amounts to a pwd which respects -C options + local context_dir=$(__git rev-parse --show-toplevel --show-prefix 2>/dev/null | paste -s -d '/' 2>/dev/null) -+ [ -d "$context_dir" ] || return ++ [ -d "$context_dir" ] || return 1 + -+ COMPREPLY=$(cd $context_dir 2>/dev/null && compgen -d -- "$cur_") ++ COMPREPLY=$(cd "$context_dir" 2>/dev/null && compgen -d -- "$cur_") +} -+ + __git_whitespacelist="nowarn warn error error-all fix" __git_patchformat="mbox stgit stgit-series hg mboxrd" -- 2.43.0