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

Re: [PATCH v2 2/2] bash completion: refactor diff options

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 20, 2009, 08:36 UTC
Message-ID
<7vwscqjrwh.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1232399880-22036-2-git-send-email-trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 74 quoted lines
> diff, log and show all take the same diff options.  Refactor them from
> __git_diff and __git_log into a variable, and complete them in
> __git_show too.
>
> Signed-off-by: Thomas Rast <trast@student.ethz.ch>
>
> ---
>  contrib/completion/git-completion.bash |   36 ++++++++++++++++++-------------
>  1 files changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 096603b..bfae953 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -773,14 +773,7 @@ _git_describe ()
>  	__gitcomp "$(__git_refs)"
>  }
>  
> -_git_diff ()
> -{
> -	__git_has_doubledash && return
> -
> -	local cur="${COMP_WORDS[COMP_CWORD]}"
> -	case "$cur" in
> -	--*)
> -		__gitcomp "--cached --stat --numstat --shortstat --summary
> +__git_diff_common_options="--stat --numstat --shortstat --summary
>  			--patch-with-stat --name-only --name-status --color
>  			--no-color --color-words --no-renames --check
>  			--full-index --binary --abbrev --diff-filter=
> @@ -789,9 +782,21 @@ _git_diff ()
>  			--ignore-all-space --exit-code --quiet --ext-diff
>  			--no-ext-diff
>  			--no-prefix --src-prefix= --dst-prefix=
> -			--base --ours --theirs
>  			--inter-hunk-context=
>  			--patience
> +			--raw
> +"
> +
> +_git_diff ()
> +{
> +	__git_has_doubledash && return
> +
> +	local cur="${COMP_WORDS[COMP_CWORD]}"
> +	case "$cur" in
> +	--*)
> +		__gitcomp "--cached --pickaxe-all --pickaxe-regex
> +			--base --ours --theirs
> +			$__git_diff_common_options
>  			"
>  		return
>  		;;
> @@ -977,17 +982,16 @@ _git_log ()
>  			--relative-date --date=
>  			--author= --committer= --grep=
>  			--all-match
> -			--pretty= --name-status --name-only --raw
> +			--pretty=
>  			--not --all
>  			--left-right --cherry-pick
>  			--graph
> -			--stat --numstat --shortstat
> -			--decorate --diff-filter=
> -			--color-words --walk-reflogs
> +			--decorate
> +			--walk-reflogs
>  			--parents --children --full-history
>  			--merge
>  			--inter-hunk-context=
> -			--patience
> +			$__git_diff_common_options
>  			--pickaxe-all --pickaxe-regex
>  			"

I'll tweak this part to drop duplicated --ihc; other than that it looked good. Thanks.

Previous: Thomas Rast
Message 8 of 8 in “bash completion: refactor diff options”
  1. bash completion: refactor diff optionsThomas Rast, Jan 11, 2009
  2. bash completion: refactor diff optionsThomas Rast, Jan 12, 2009
  3. bash completion: refactor diff optionsThomas Rast, Jan 18, 2009
  4. Junio C HamanoJan 18, 2009
  5. Shawn O. PearceJan 19, 2009
  6. 1/2 bash completion: move pickaxe options to logThomas Rast, Jan 19, 2009
  7. 2/2 bash completion: refactor diff optionsThomas Rast, Jan 19, 2009
  8. Junio C HamanoJan 20, 2009

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.