]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: bisect: complete log opts for visualize subcommand
authorBritton Leo Kerin <britton.kerin@gmail.com>
Tue, 6 Feb 2024 21:50:47 +0000 (12:50 -0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Feb 2024 23:11:46 +0000 (15:11 -0800)
Arguments passed to the "visualize" subcommand of git-bisect(1) get
forwarded to git-log(1). It thus supports the same options as git-log(1)
would, but our Bash completion script does not know to handle this.

Make completion of porcelain git-log options and option arguments to the
visualize subcommand work by calling __git_complete_log_opts when the
start of an option to the subcommand is seen (visualize doesn't support
any options besides the git-log options).  Add test.

Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash
t/t9902-completion.sh

index b9ebd5e4095de23f2629cd1e832a37468b77bea6..5337ae4ce2b7982c3bdf5df36507e3cdce8e87ff 100644 (file)
@@ -1490,6 +1490,10 @@ _git_bisect ()
                __gitcomp "--term-good --term-old --term-bad --term-new"
                return
                ;;
+       visualize)
+               __git_complete_log_opts
+               return
+               ;;
        bad|new|"$term_bad"|good|old|"$term_good"|reset|skip)
                __git_complete_refs
                ;;
index 8fcd1cfa7ef8fcdf40aa2f809dcae116290fd467..b989388e7ea73100ae4889ddfb64e3252d65fb30 100755 (executable)
@@ -1361,6 +1361,21 @@ test_expect_success 'git-bisect - options to terms subcommand are candidates' '
        )
 '
 
+test_expect_success 'git-bisect - git-log options to visualize subcommand are candidates' '
+       (
+               cd git-bisect &&
+               # The completion used for git-log and here does not complete
+               # every git-log option, so rather than hope to stay in sync
+               # with exactly what it does we will just spot-test here.
+               test_completion "git bisect visualize --sta" <<-\EOF &&
+               --stat Z
+               EOF
+               test_completion "git bisect visualize --summar" <<-\EOF
+               --summary Z
+               EOF
+       )
+'
+
 test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
        test_completion "git checkout " <<-\EOF
        HEAD Z