git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v5 0/7] completion: improvements for git-bisect

From
Britton Leo Kerin <britton.kerin@gmail.com>
Date
Feb 6, 2024, 02:09 UTC
Message-ID
<20240206020930.312164-1-britton.kerin@gmail.com>
In-Reply-To
<20240128223447.342493-1-britton.kerin@gmail.com>
Relative to v4 this make the following actual changes:
  * fixes GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME to 'master' for all of
    t9902-completion.sh as suggested by Junio.  This change affects all
    of t9902-completion.sh so I've put it by itself in it's own commit.
  * uses BISECT_TERMS to avoid pointless processes as suggested by Patrick.
The commits are also refactored as follows:
  * squashes the introduction of __git_complete_log_opts in with it's
    first use a suggested by Patrick.
  * spreads tests across commits as suggest by Patrick.
Thanks for the reviews.
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 subcommand
 contrib/completion/git-completion.bash |  65 ++++++++++--
 t/t9902-completion.sh                  | 140 +++++++++++++++++++++++++
 2 files changed, 198 insertions(+), 7 deletions(-)
Range-diff against v4:
1:  66153024c3 < -:  ---------- completion: bisect: complete bad, new, old, and help subcommands
-:  ---------- > 1:  71b73de914 completion: tests: always use 'master' for default initial branch name
8:  451b7a4467 ! 2:  3a478a7a08 completion: add tests for git-bisect
    @@ Metadata
     Author: Britton Leo Kerin <britton.kerin@gmail.com>
      ## Commit message ##
    -    completion: add tests for git-bisect
    +    completion: bisect: complete bad, new, old, and help subcommands
    -    There aren't any tests for completion of git bisect and it's
    -    subcommands.
    +    The bad, new, old and help subcommands to git-bisect(1) are not
    +    completed.
    +    Add the bad, new, old, and help subcommands to the appropriate lists
    +    such that the commands and their possible ref arguments are completed.
         Add tests.
    +    Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.c
    +
    + ## contrib/completion/git-completion.bash ##
    +@@ contrib/completion/git-completion.bash: _git_bisect ()
    + {
    + 	__git_has_doubledash && return
    +
    +-	local subcommands="start bad good skip reset visualize replay log run"
    ++	local subcommands="start bad new good old skip reset visualize replay log run help"
    + 	local subcommand="$(__git_find_on_cmdline "$subcommands")"
    + 	if [ -z "$subcommand" ]; then
    + 		__git_find_repo_path
    +@@ contrib/completion/git-completion.bash: _git_bisect ()
    + 	fi
    +
    + 	case "$subcommand" in
    +-	bad|good|reset|skip|start)
    ++	bad|new|good|old|reset|skip|start)
    + 		__git_complete_refs
    + 		;;
    + 	*)
    +
      ## t/t9902-completion.sh ##
     @@ t/t9902-completion.sh: test_expect_success 'git switch - with no options, complete local branches and u
      	EOF
    @@ t/t9902-completion.sh: test_expect_success 'git switch - with no options, comple
     +	EOF
     +'
     +
    -+test_expect_success 'git bisect - complete options to start subcommand' '
    -+	test_completion "git bisect start --" <<-\EOF
    -+	--term-new Z
    -+	--term-bad Z
    -+	--term-old Z
    -+	--term-good Z
    -+	--no-checkout Z
    -+	--first-parent Z
    -+	EOF
    -+'
    -+
     +test_expect_success 'setup for git-bisect tests requiring a repo' '
     +	git init git-bisect &&
     +	(
    @@ t/t9902-completion.sh: test_expect_success 'git switch - with no options, comple
     +		test_completion "git bisect " <<-\EOF
     +		start Z
     +		bad Z
    -+		custom_new Z
    -+		custom_old Z
     +		new Z
     +		good Z
     +		old Z
    -+		terms Z
     +		skip Z
     +		reset Z
     +		visualize Z
    @@ t/t9902-completion.sh: test_expect_success 'git switch - with no options, comple
     +		EOF
     +	)
     +'
    -+test_expect_success 'git-bisect - options to terms subcommand are candidates' '
    -+	(
    -+		cd git-bisect &&
    -+		test_completion "git bisect terms --" <<-\EOF
    -+		--term-bad Z
    -+		--term-good Z
    -+		--term-new Z
    -+		--term-old Z
    -+		EOF
    -+	)
    -+'
    -+
    -+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-bisect - view subcommand is not a candidate' '
    -+	(
    -+		cd git-bisect &&
    -+		test_completion "git bisect vi" <<-\EOF
    -+		visualize Z
    -+		EOF
    -+	)
    -+'
    -+
    -+test_expect_success 'git-bisect - existing view subcommand is recognized and enables completion of git-log options' '
    -+	(
    -+		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 view --sta" <<-\EOF &&
    -+		--stat Z
    -+		EOF
    -+		test_completion "git bisect view --summar" <<-\EOF
    -+		--summary Z
    -+		EOF
    -+	)
    -+'
     +
      test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
      	test_completion "git checkout " <<-\EOF
2:  7eb8c842a3 ! 3:  fab7159cf4 completion: bisect: complete custom terms and related options
    @@ Commit message
         these options or the new subcommands they define.
         Add support for these options and the custom subcommands by checking for
    -    them if a bisection is in progress and adding them to the list of
    -    subcommands.
    +    BISECT_TERMS and adding them to the list of subcommands.  Add tests.
         Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
    @@ contrib/completion/git-completion.bash: _git_bisect ()
     +
     +	# If a bisection is in progress get the terms being used.
     +	local term_bad term_good
    -+	if [ -f "$__git_repo_path"/BISECT_START ]; then
    ++	if [ -f "$__git_repo_path"/BISECT_TERMS ]; then
     +		term_bad=$(__git bisect terms --term-bad)
     +		term_good=$(__git bisect terms --term-good)
     +	fi
    @@ contrib/completion/git-completion.bash: _git_bisect ()
      		__git_complete_refs
      		;;
      	*)
    +
    + ## t/t9902-completion.sh ##
    +@@ t/t9902-completion.sh: test_expect_success 'git-bisect - when bisecting all subcommands are candidates'
    + 		test_completion "git bisect " <<-\EOF
    + 		start Z
    + 		bad Z
    ++		custom_new Z
    ++		custom_old Z
    + 		new Z
    + 		good Z
    + 		old Z
    ++		terms Z
    + 		skip Z
    + 		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 &&
    ++		test_completion "git bisect terms --" <<-\EOF
    ++		--term-bad Z
    ++		--term-good Z
    ++		--term-new Z
    ++		--term-old Z
    ++		EOF
    ++	)
    ++'
    ++
    +
    + test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
    + 	test_completion "git checkout " <<-\EOF
3:  5f5076bb93 < -:  ---------- completion: bisect: complete missing --first-parent and --no-checkout options
4:  c8ffa0e915 < -:  ---------- completion: new function __git_complete_log_opts
5:  733613d1ed < -:  ---------- completion: log: use __git_complete_log_opts
-:  ---------- > 4:  73f3343b94 completion: bisect: complete missing --first-parent and --no-checkout options
-:  ---------- > 5:  a20846bbd3 completion: new function __git_complete_log_opts
6:  06f5973b3b ! 6:  fe5545c9a3 completion: bisect: complete log opts for visualize subcommand
    @@ Commit message
         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).
    +    any options besides the git-log options).  Add test.
         Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
    @@ contrib/completion/git-completion.bash: _git_bisect ()
      	bad|new|"$term_bad"|good|old|"$term_good"|reset|skip)
      		__git_complete_refs
      		;;
    +
    + ## t/t9902-completion.sh ##
    +@@ t/t9902-completion.sh: 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
7:  1dc9323f24 ! 7:  c9102ac532 completion: bisect: recognize but do not complete view subcommand
    @@ Commit message
         completion for it.
         Recognize but do not complete the view command by creating and using
    -    separate lists of completable_subcommands and all_subcommands.
    +    separate lists of completable_subcommands and all_subcommands.  Add
    +    tests.
         Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
    @@ contrib/completion/git-completion.bash: _git_bisect ()
      		__git_complete_log_opts
      		return
      		;;
    +
    + ## t/t9902-completion.sh ##
    +@@ t/t9902-completion.sh: test_expect_success 'git-bisect - git-log options to visualize subcommand are ca
    + 	)
    + '
    +
    ++test_expect_success 'git-bisect - view subcommand is not a candidate' '
    ++	(
    ++		cd git-bisect &&
    ++		test_completion "git bisect vi" <<-\EOF
    ++		visualize Z
    ++		EOF
    ++	)
    ++'
    ++
    ++test_expect_success 'git-bisect - existing view subcommand is recognized and enables completion of git-log options' '
    ++	(
    ++		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 view --sta" <<-\EOF &&
    ++		--stat Z
    ++		EOF
    ++		test_completion "git bisect view --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
--
2.43.0
Previous: Patrick SteinhardtNext: Britton Leo Kerin
Message 32 of 58 in “completion: improvements for git-bisect”
  1. 0/6 completion: improvements for git-bisectBritton Leo Kerin, Jan 2, 2024
  2. 0/5 completion: improvements for git-bisectBritton Leo Kerin, Jan 10, 2024
  3. 0/5 completion: improvements for git-bisectBritton Leo Kerin, Jan 18, 2024
  4. 1/5 completion: complete new old actions, start optsBritton Leo Kerin, Jan 18, 2024
  5. Patrick SteinhardtJan 19, 2024
  6. 2/5 completion: git-log opts to bisect visualizeBritton Leo Kerin, Jan 18, 2024
  7. Patrick SteinhardtJan 19, 2024
  8. 3/5 completion: move to maintain define-before-useBritton Leo Kerin, Jan 18, 2024
  9. Patrick SteinhardtJan 19, 2024
  10. 4/5 completion: custom git-bisect termsBritton Leo Kerin, Jan 18, 2024
  11. Patrick SteinhardtJan 19, 2024
  12. 5/5 completion: git-bisect view recognized but not completedBritton Leo Kerin, Jan 18, 2024
  13. Patrick SteinhardtJan 19, 2024
  14. Patrick SteinhardtJan 19, 2024
  15. Junio C HamanoJan 19, 2024
  16. Britton KerinJan 26, 2024
  17. 0/8 completion: improvements for git-bisectBritton Leo Kerin, Jan 28, 2024
  18. 2/8 completion: bisect: complete custom terms and related optionsBritton Leo Kerin, Jan 28, 2024
  19. Patrick SteinhardtFeb 1, 2024
  20. 4/8 completion: new function __git_complete_log_optsBritton Leo Kerin, Jan 28, 2024
  21. 3/8 completion: bisect: complete missing --first-parent and --no-checkout optionsBritton Leo Kerin, Jan 28, 2024
  22. 1/8 completion: bisect: complete bad, new, old, and help subcommandsBritton Leo Kerin, Jan 28, 2024
  23. Patrick SteinhardtFeb 1, 2024
  24. 5/8 completion: log: use __git_complete_log_optsBritton Leo Kerin, Jan 28, 2024
  25. Patrick SteinhardtFeb 1, 2024
  26. 6/8 completion: bisect: complete log opts for visualize subcommandBritton Leo Kerin, Jan 28, 2024
  27. 7/8 completion: bisect: recognize but do not complete view subcommandBritton Leo Kerin, Jan 28, 2024
  28. 8/8 completion: add tests for git-bisectBritton Leo Kerin, Jan 28, 2024
  29. Junio C HamanoJan 30, 2024
  30. Patrick SteinhardtFeb 1, 2024
  31. Patrick SteinhardtFeb 1, 2024
  32. 0/7 completion: improvements for git-bisectBritton Leo Kerin, Feb 6, 2024
  33. 1/7 completion: tests: always use 'master' for default initial branch nameBritton Leo Kerin, Feb 6, 2024
  34. 2/7 completion: bisect: complete bad, new, old, and help subcommandsBritton Leo Kerin, Feb 6, 2024
  35. Patrick SteinhardtFeb 6, 2024
  36. 3/7 completion: bisect: complete custom terms and related optionsBritton Leo Kerin, Feb 6, 2024
  37. Patrick SteinhardtFeb 6, 2024
  38. 4/7 completion: bisect: complete missing --first-parent and --no-checkout optionsBritton Leo Kerin, Feb 6, 2024
  39. 5/7 completion: new function __git_complete_log_optsBritton Leo Kerin, Feb 6, 2024
  40. Patrick SteinhardtFeb 6, 2024
  41. 7/7 completion: bisect: recognize but do not complete view subcommandBritton Leo Kerin, Feb 6, 2024
  42. 6/7 completion: bisect: complete log opts for visualize subcommandBritton Leo Kerin, Feb 6, 2024
  43. Patrick SteinhardtFeb 6, 2024
  44. 0/7 completion: improvements for git-bisectBritton Leo Kerin, Feb 6, 2024
  45. 3/7 completion: bisect: complete custom terms and related optionsBritton Leo Kerin, Feb 6, 2024
  46. 2/7 completion: bisect: complete bad, new, old, and help subcommandsBritton Leo Kerin, Feb 6, 2024
  47. 4/7 completion: bisect: complete missing --first-parent and --no-checkout optionsBritton Leo Kerin, Feb 6, 2024
  48. 1/7 completion: tests: always use 'master' for default initial branch nameBritton Leo Kerin, Feb 6, 2024
  49. 5/7 completion: new function __git_complete_log_optsBritton Leo Kerin, Feb 6, 2024
  50. 7/7 completion: bisect: recognize but do not complete view subcommandBritton Leo Kerin, Feb 6, 2024
  51. 6/7 completion: bisect: complete log opts for visualize subcommandBritton Leo Kerin, Feb 6, 2024
  52. Junio C HamanoFeb 6, 2024
  53. Patrick SteinhardtFeb 7, 2024
  54. 4/5 completion: custom git-bisect termsBritton Leo Kerin, Jan 10, 2024
  55. 1/5 completion: complete new old actions, start optsBritton Leo Kerin, Jan 10, 2024
  56. 2/5 completion: git-log opts to bisect visualizeBritton Leo Kerin, Jan 10, 2024
  57. 3/5 completion: move to maintain define-before-useBritton Leo Kerin, Jan 10, 2024
  58. 5/5 completion: custom git-bisect termsBritton Leo Kerin, Jan 10, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.