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

[RFC PATCH 2/6] completion: git-log opts to bisect visualize

From
Britton Leo Kerin <britton.kerin@gmail.com>
Date
Jan 2, 2024, 19:57 UTC
Message-ID
<66708709-247c-49ea-afda-6ac607159795@smtp-relay.sendinblue.com>
In-Reply-To
<20240102195744.478503-1-britton.kerin@gmail.com>

To do this the majority of _git_log has been factored out into the new __git_complete_log_opts. This is needed because the visualize command accepts git-log options but not rev arguments (they are fixed to the commits under bisection).

Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
 contrib/completion/git-completion.bash | 30 ++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 15d22ff7d9..3472fab514 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1472,6 +1472,16 @@ _git_bisect ()
 			;;
 		esac
 		;;
+	visualize)
+		case "$cur" in
+		-*)
+			__git_complete_log_opts
+			return
+			;;
+		*)
+			;;
+		esac
+		;;
 	esac
 
 	case "$subcommand" in
@@ -2074,11 +2084,12 @@ __git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-c
 __git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
 __git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:"
 
-_git_log ()
-{
-	__git_has_doubledash && return
-	__git_find_repo_path
 
+# Find only porcelain (i.e. not git-rev-list) option (not argument) and
+# selected option argument completions for git-log options and put them in
+# COMPREPLY.
+__git_complete_log_opts ()
+{
 	local merge=""
 	if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
 		merge="--merge"
@@ -2171,6 +2182,17 @@ _git_log ()
 		return
 		;;
 	esac
+
+}
+
+_git_log ()
+{
+	__git_has_doubledash && return
+	__git_find_repo_path
+
+        __git_complete_log_opts
+        [ -z "$COMPREPLY" ] || return
+
 	__git_complete_revlist
 }
 
-- 
2.43.0
Previous: Britton Leo KerinNext: Britton Leo Kerin
Message 2 of 6 in “completion: complete new old actions, start opts”
  1. 1/6 completion: complete new old actions, start optsBritton Leo Kerin, Jan 2, 2024
  2. 2/6 completion: git-log opts to bisect visualizeBritton Leo Kerin, Jan 2, 2024
  3. 4/6 completion: custom git-bisect termsBritton Leo Kerin, Jan 2, 2024
  4. 3/6 completion: move to maintain define-before-useBritton Leo Kerin, Jan 2, 2024
  5. 6/6 completion: add commentBritton Leo Kerin, Jan 2, 2024
  6. 5/6 completion: recognize but do not complete 'view'Britton Leo Kerin, Jan 2, 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.