Subject: Re: [PATCH v4 5/8] completion: log: use __git_complete_log_opts

From: Patrick Steinhardt <[email-masked]>
Date: Thu, 1 Feb 2024 10:55:32 +0100

On Sun, Jan 28, 2024 at 01:34:44PM -0900, Britton Leo Kerin wrote:
> Use the new __git_complete_log_opts function to handle option and
> optiona rgument completion in _git_log.

I think this commit could be merged with the preceding one to clarify
that this really only is a move of code. Sorry if my comments on the
previous round weren't clear on that.

Patrick

> Signed-off-by: Britton Leo Kerin <[email-masked]>
> ---
>  contrib/completion/git-completion.bash | 95 +-------------------------
>  1 file changed, 3 insertions(+), 92 deletions(-)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index dfd504c37e..41c76c1246 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2195,98 +2195,9 @@ _git_log ()
>  	__git_has_doubledash && return
>  	__git_find_repo_path
>  
> -	local merge=""
> -	if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
> -		merge="--merge"
> -	fi
> -	case "$prev,$cur" in
> -	-L,:*:*)
> -		return	# fall back to Bash filename completion
> -		;;
> -	-L,:*)
> -		__git_complete_symbol --cur="${cur#:}" --sfx=":"
> -		return
> -		;;
> -	-G,*|-S,*)
> -		__git_complete_symbol
> -		return
> -		;;
> -	esac
> -	case "$cur" in
> -	--pretty=*|--format=*)
> -		__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
> -			" "" "${cur#*=}"
> -		return
> -		;;
> -	--date=*)
> -		__gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
> -		return
> -		;;
> -	--decorate=*)
> -		__gitcomp "full short no" "" "${cur##--decorate=}"
> -		return
> -		;;
> -	--diff-algorithm=*)
> -		__gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
> -		return
> -		;;
> -	--submodule=*)
> -		__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
> -		return
> -		;;
> -	--ws-error-highlight=*)
> -		__gitcomp "$__git_ws_error_highlight_opts" "" "${cur##--ws-error-highlight=}"
> -		return
> -		;;
> -	--no-walk=*)
> -		__gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
> -		return
> -		;;
> -	--diff-merges=*)
> -                __gitcomp "$__git_diff_merges_opts" "" "${cur##--diff-merges=}"
> -                return
> -                ;;
> -	--*)
> -		__gitcomp "
> -			$__git_log_common_options
> -			$__git_log_shortlog_options
> -			$__git_log_gitk_options
> -			$__git_log_show_options
> -			--root --topo-order --date-order --reverse
> -			--follow --full-diff
> -			--abbrev-commit --no-abbrev-commit --abbrev=
> -			--relative-date --date=
> -			--pretty= --format= --oneline
> -			--show-signature
> -			--cherry-mark
> -			--cherry-pick
> -			--graph
> -			--decorate --decorate= --no-decorate
> -			--walk-reflogs
> -			--no-walk --no-walk= --do-walk
> -			--parents --children
> -			--expand-tabs --expand-tabs= --no-expand-tabs
> -			$merge
> -			$__git_diff_common_options
> -			"
> -		return
> -		;;
> -	-L:*:*)
> -		return	# fall back to Bash filename completion
> -		;;
> -	-L:*)
> -		__git_complete_symbol --cur="${cur#-L:}" --sfx=":"
> -		return
> -		;;
> -	-G*)
> -		__git_complete_symbol --pfx="-G" --cur="${cur#-G}"
> -		return
> -		;;
> -	-S*)
> -		__git_complete_symbol --pfx="-S" --cur="${cur#-S}"
> -		return
> -		;;
> -	esac
> +	__git_complete_log_opts
> +	[ -z "$COMPREPLY" ] || return
> +
>  	__git_complete_revlist
>  }
>  
> -- 
> 2.43.0
>