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

Re: [PATCH] completion: add missing completions for log, diff, show

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 8, 2017, 02:33 UTC
Message-ID
<xmqq7ev1mrdi.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<0102015f985d387e-f50183c4-4b49-4a9f-b365-2a86ba24bbed-000000@eu-west-1.amazonses.com>
Max Rothman <max.r.rothman@gmail.com> writes:
> From: Max Rothman <max-rothman@pluralsight.com>
Thanks.
Show 12 quoted lines
>
> Teach git-log tab completion about the --no-* options for ease of use
> at the command line.
>
> Similarly, teach git-show tab completion about the --no-abbrev-commit,
> --expand-tabs, and --no-expand-tabs options.
>
> Also, teach git-diff (and all commands that use its options) tab
> completion about the --textconv and --indent-heuristic families of
> options. --indent-heuristic is no longer experimental, so there's no
> reason it should be left out of tab completion any more, and textconv
> seems to have simply been missed.

A couple of things that I found questionable in the above descriptions are:

 * We do not write git subcommand names like git-foo these days, as
   nobody type them like so.
 * The patch is not teaching git-foo about completing its options.
   It teaches the bash completion about options for git subcommands
   it did not know about.
So perhaps
	The bash completion script knows some options to the "git
	log" only in the positive form (e.g. "--abbrev-commit") but
	not in their negated form (e.g. "--no-abbrev-commit").  Add
	them.
and similar?
> ---
Missed sign-off?
Show 17 quoted lines
> @@ -1759,16 +1765,19 @@ _git_log ()
> ...
> -			--decorate --decorate=
> +			--decorate --decorate= --no-decorate
> ...
> @@ -2816,8 +2825,9 @@ _git_show ()
>  		return
>  		;;
>  	--*)
> -		__gitcomp "--pretty= --format= --abbrev-commit --oneline
> -			--show-signature
> +		__gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
> +			--oneline --show-signature --patch
> +			--expand-tabs --expand-tabs= --no-expand-tabs
>  			$__git_diff_common_options
>  			"
>  		return

It's a bit sad that the completion support does not know that "git show" belongs to the "git log" family of commands. A consequence of this is that "git show --no-decorate" is perfectly acceptable but needs to be taught separately to _git_show if we wanted to.

Perhaps some selected options _git_log understands may need to be split $__git_log_ui_common_options [*1*], like we do for "git diff" family with $__git_diff_common_options, and shared between _git_log and _git_show.

I am mentioning this primarily as #leftoverbits and I do not want to see such a change mixed into this patch, as it is totally outside the scope of it. It is (if you are inclined to do so) OK to make this into two patch series, with 1/2 doing such a refactoring without changing any externally visible functionality (i.e. just move the ones _git_show knows about to $__git_log_ui_common_options, and have _git_show and _git_log use it), and 2/2 adding more options to that list to achieve what you wanted to do with this patch, though.

Thanks.
[Footnote]
*1* $__git_log_common_options is taken and it is about options
    common to "log/shortlog/gitk" but contains some that are not
    relevant to "git show", and that is why I am suggesting a
    separate and new variable.
Previous: Max RothmanNext: Max Rothman
Message 11 of 19 in “No log --no-decorate completion?”
  1. Max RothmanOct 11, 2017
  2. Stefan BellerOct 11, 2017
  3. Max RothmanOct 12, 2017
  4. Max RothmanOct 24, 2017
  5. Stefan BellerOct 24, 2017
  6. Max RothmanNov 2, 2017
  7. Stefan BellerNov 2, 2017
  8. Max RothmanNov 7, 2017
  9. Stefan BellerNov 7, 2017
  10. completion: add missing completions for log, diff, showMax Rothman, Nov 7, 2017
  11. Junio C HamanoNov 8, 2017
  12. Max RothmanNov 8, 2017
  13. Junio C HamanoNov 8, 2017
  14. completion: add missing completions for log, diff, showMax Rothman, Jul 2, 2019
  15. Max RothmanAug 2, 2019
  16. Max RothmanSep 11, 2019
  17. Johannes SchindelinSep 12, 2019
  18. Junio C HamanoSep 12, 2019
  19. Johannes SchindelinSep 13, 2019

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.