[PATCH v6 0/7] completion: improvements for git-bisect
- From
Britton Leo Kerin <britton.kerin@gmail.com>
- Date
- Feb 6, 2024, 21:50 UTC
- Message-ID
- <20240206215048.488344-1-britton.kerin@gmail.com>
- In-Reply-To
- <20240206020930.312164-1-britton.kerin@gmail.com>
Relative to v5 this makes the following actual changes:
* Treat COMPREPLY as an array on assignment and test, rather than
relying on the bash mechanism of implicitly acting on the first
element of the array.* Whitespace fixes.
The commit message about __git_complete_log_opts has also been changed to indicate that COMPREPLY is emptied and why, and a broken Signed-off-by line fixed.
Britton Leo Kerin (7):
completion: tests: always use 'master' for default initial branch name
completion: bisect: complete bad, new, old, and help subcommands
completion: bisect: complete custom terms and related options
completion: bisect: complete missing --first-parent and --no-checkout
options
completion: new function __git_complete_log_opts
completion: bisect: complete log opts for visualize subcommand
completion: bisect: recognize but do not complete view subcommandcontrib/completion/git-completion.bash | 65 ++++++++++-- t/t9902-completion.sh | 141 +++++++++++++++++++++++++ 2 files changed, 199 insertions(+), 7 deletions(-)
Range-diff against v5:
1: 71b73de914 = 1: 71b73de914 completion: tests: always use 'master' for default initial branch name
2: 3a478a7a08 ! 2: 7bc45bfc13 completion: bisect: complete bad, new, old, and help subcommands
@@ Commit message
such that the commands and their possible ref arguments are completed.
Add tests. - Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.c
+ Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com> ## contrib/completion/git-completion.bash ##
@@ contrib/completion/git-completion.bash: _git_bisect ()
3: fab7159cf4 ! 3: be925327d3 completion: bisect: complete custom terms and related options
@@ t/t9902-completion.sh: test_expect_success 'git-bisect - when bisecting all subc
reset Z
visualize Z
@@ t/t9902-completion.sh: test_expect_success 'git-bisect - when bisecting all subcommands are candidates'
- EOF
)
'
+
+test_expect_success 'git-bisect - options to terms subcommand are candidates' '
+ (
+ cd git-bisect &&
@@ t/t9902-completion.sh: test_expect_success 'git-bisect - when bisecting all subc
+ )
+'
+
-
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
test_completion "git checkout " <<-\EOF
+ HEAD Z
4: 73f3343b94 = 4: c3141921e5 completion: bisect: complete missing --first-parent and --no-checkout options
5: a20846bbd3 ! 5: 092bfba6b1 completion: new function __git_complete_log_opts
@@ Commit message
completion: new function __git_complete_log_opts The options accepted by git-log are also accepted by at least one other
- command (git-bisect). Factor the common option completion code into
- a new function and use it from _git_log.
+ command (git-bisect). Factor the common option completion code into a
+ new function and use it from _git_log. The new function leaves
+ COMPREPLY empty if no option candidates are found, so that callers can
+ safely check it to determine if completion for other arguments should be
+ attempted.Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
@@ contrib/completion/git-completion.bash: __git_diff_merges_opts="off none on firs
{
- __git_has_doubledash && return
- __git_find_repo_path
-+ COMPREPLY=""
++ COMPREPLY=() local merge=""
if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
@@ contrib/completion/git-completion.bash: _git_log ()
+ __git_find_repo_path
+
+ __git_complete_log_opts
-+ [ -z "$COMPREPLY" ] || return
++ [ ${#COMPREPLY[@]} -eq 0 ] || return
+
__git_complete_revlist
}
6: fe5545c9a3 ! 6: 9afd4d4e0f completion: bisect: complete log opts for visualize subcommand
@@ t/t9902-completion.sh: test_expect_success 'git-bisect - options to terms subcom
+ EOF
+ )
+'
-
++
test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
test_completion "git checkout " <<-\EOF
+ HEAD Z
7: c9102ac532 = 7: dba916b31c completion: bisect: recognize but do not complete view subcommand
--
2.43.0