[PATCH v2 0/1] completion: complete dir-type option args to am, format_patch
- From
Britton Leo Kerin <britton.kerin@gmail.com>
- Date
- Jan 9, 2024, 00:53 UTC
- Message-ID
- <feae3401-b3cb-4bae-926b-4844b0b0986c@smtp-relay.sendinblue.com>
- In-Reply-To
- <4714b88d-df5b-4e37-a5d7-af5033cfb861@smtp-relay.sendinblue.com>
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