threads / discuss / 46949

No log --no-decorate completion?

Subject: No log --no-decorate completion?

## tl;dr

19 messages between Oct 11, 2017 and Sep 13, 2019.

replies: 18people: 4as markdown or json

Max Rothman· Oct 11, 2017, 14:47 UTC · lore

I recently noticed that in the git-completion script, there's completion for --decorate={full,yes,no} for git log and family, but not for --no-decorate. Is that intentional? If not, I *think* I see how it could be added.

Thanks, Max

Stefan Beller· Oct 11, 2017, 18:09 UTC · re: Max Rothman · lore

Re: No log --no-decorate completion?

On Wed, Oct 11, 2017 at 7:47 AM, Max Rothman <max.r.rothman@gmail.com> wrote:
Show 7 quoted lines
> I recently noticed that in the git-completion script, there's
> completion for --decorate={full,yes,no} for git log and family, but
> not for --no-decorate. Is that intentional? If not, I *think* I see
> how it could be added.
>
> Thanks,
> Max

Using git-blame, I found af4e9e8c87 (completion: update am, commit, and log, 2009-10-07) as well as af16bdaa3f (completion: fix and update 'git log --decorate=' options, 2015-05-01), both of their commit messages do not discuss leaving out --no-decorate intentionally.

If you give --no-<TAB> you'd get more than just the completion to --no-decorate, but all the negated options, I would assume?

So maybe that is why no one added the negated options, yet?

Thanks, Stefan

Max Rothman· Oct 12, 2017, 17:41 UTC · re: Stefan Beller · lore

Re: No log --no-decorate completion?

To be fair, other --no* options complete, it's just --no-decorate, --no-walk, --no-abbrev-commit, --no-expand-tabs, --no-patch, --no-indent-heuristic, and --no-textconv that's missing.

For example:
$ git log --no<TAB><TAB>
--no-color         --no-max-parents   --no-min-parents   --no-prefix
     --not
--no-ext-diff      --no-merges        --no-notes         --no-renames
     --notes

Thanks, Max

On Wed, Oct 11, 2017 at 2:09 PM, Stefan Beller <sbeller@google.com> wrote:
Show 22 quoted lines
> On Wed, Oct 11, 2017 at 7:47 AM, Max Rothman <max.r.rothman@gmail.com> wrote:
>> I recently noticed that in the git-completion script, there's
>> completion for --decorate={full,yes,no} for git log and family, but
>> not for --no-decorate. Is that intentional? If not, I *think* I see
>> how it could be added.
>>
>> Thanks,
>> Max
>
> Using git-blame, I found af4e9e8c87 (completion: update am, commit, and log,
> 2009-10-07) as well as af16bdaa3f (completion: fix and update 'git log
> --decorate='
> options, 2015-05-01), both of their commit messages do not discuss leaving out
> --no-decorate intentionally.
>
> If you give --no-<TAB> you'd get more than just the completion to --no-decorate,
> but all the negated options, I would assume?
>
> So maybe that is why no one added the negated options, yet?
>
> Thanks,
> Stefan
Max Rothman· Oct 24, 2017, 15:32 UTC · re: Max Rothman · lore

Re: No log --no-decorate completion?

Just re-discovered this in my inbox. So is this worth fixing? I could (probably) figure out a patch.

Thanks, Max

On Thu, Oct 12, 2017 at 1:41 PM, Max Rothman <max.r.rothman@gmail.com> wrote:
Show 37 quoted lines
> To be fair, other --no* options complete, it's just --no-decorate,
> --no-walk, --no-abbrev-commit, --no-expand-tabs, --no-patch,
> --no-indent-heuristic, and --no-textconv that's missing.
>
> For example:
> $ git log --no<TAB><TAB>
> --no-color         --no-max-parents   --no-min-parents   --no-prefix
>      --not
> --no-ext-diff      --no-merges        --no-notes         --no-renames
>      --notes
>
> Thanks,
> Max
>
> On Wed, Oct 11, 2017 at 2:09 PM, Stefan Beller <sbeller@google.com> wrote:
>> On Wed, Oct 11, 2017 at 7:47 AM, Max Rothman <max.r.rothman@gmail.com> wrote:
>>> I recently noticed that in the git-completion script, there's
>>> completion for --decorate={full,yes,no} for git log and family, but
>>> not for --no-decorate. Is that intentional? If not, I *think* I see
>>> how it could be added.
>>>
>>> Thanks,
>>> Max
>>
>> Using git-blame, I found af4e9e8c87 (completion: update am, commit, and log,
>> 2009-10-07) as well as af16bdaa3f (completion: fix and update 'git log
>> --decorate='
>> options, 2015-05-01), both of their commit messages do not discuss leaving out
>> --no-decorate intentionally.
>>
>> If you give --no-<TAB> you'd get more than just the completion to --no-decorate,
>> but all the negated options, I would assume?
>>
>> So maybe that is why no one added the negated options, yet?
>>
>> Thanks,
>> Stefan
Stefan Beller· Oct 24, 2017, 15:32 UTC · lore

Re: No log --no-decorate completion?

On Tue, Oct 24, 2017 at 8:15 AM, Max Rothman <max.r.rothman@gmail.com> wrote:
Show 6 quoted lines
> Just re-discovered this in my inbox. So is this worth fixing? I could
> (probably) figure out a patch.
>
> Thanks,
> Max
>

$ git log -- <TAB> Display all 100 possibilities? (y or n)

I guess adding one more option is no big deal, so go for it! We also have a couple --no-options already (as you said earlier), which I think makes it even more viable.

Tangent: I wonder if we can cascade the completion by common prefixes, e.g. --no- or --ignore- occurs a couple of times, such that we could only show these --no- once and only if you try autocompleting thereafter you get all --no- options.

Thanks for reviving this thread! Stefan

Max Rothman· Nov 2, 2017, 20:25 UTC · re: Stefan Beller · lore

Re: No log --no-decorate completion?

No problem! Let me know if I've done something wrong with this patch, I'm new to git's contributor process.

completion: add missing completions for log, diff, show
* Add bash completion for the missing --no-* options on git log
* Add bash completion for --textconv and --indent-heuristic families to
  git diff and all commands that use diff's options
* Add bash completion for --no-abbrev-commit, --expand-tabs, and
  --no-expand-tabs to git show
---
 contrib/completion/git-completion.bash | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash
b/contrib/completion/git-completion.bash
index 0e16f017a4144..252a6c8c0c80c 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1412,6 +1412,8 @@ __git_diff_common_options="--stat --numstat
--shortstat --summary
                        --dirstat-by-file= --cumulative
                        --diff-algorithm=
                        --submodule --submodule=
+                       --indent-heuristic --no-indent-heuristic
+                       --textconv --no-textconv
 "

 _git_diff ()
@@ -1752,6 +1754,10 @@ _git_log ()
                __gitcomp "$__git_diff_submodule_formats" ""
"${cur##--submodule=}"
                return
                ;;
+       --no-walk=*)
+               __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
+               return
+               ;;
        --*)
                __gitcomp "
                        $__git_log_common_options
@@ -1759,16 +1765,19 @@ _git_log ()
                        $__git_log_gitk_options
                        --root --topo-order --date-order --reverse
                        --follow --full-diff
-                       --abbrev-commit --abbrev=
+                       --abbrev-commit --no-abbrev-commit --abbrev=
                        --relative-date --date=
                        --pretty= --format= --oneline
                        --show-signature
                        --cherry-mark
                        --cherry-pick
                        --graph
-                       --decorate --decorate=
+                       --decorate --decorate= --no-decorate
                        --walk-reflogs
+                       --no-walk --no-walk= --do-walk
                        --parents --children
+                       --expand-tabs --expand-tabs= --no-expand-tabs
+                       --patch
                        $merge
                        $__git_diff_common_options
                        --pickaxe-all --pickaxe-regex
@@ -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

On Tue, Oct 24, 2017 at 11:32 AM, Stefan Beller <sbeller@google.com> wrote:
> On Tue, Oct 24, 2017 at 8:15 AM, Max Rothman <max.r.rothman@gmail.com> wrote:
>> Just re-discovered this in my inbox. So is this worth fixing? I could
>> (probably) figure out a patch.
>>
>> Thanks,
>> Max
>>
>
> $ git log -- <TAB>
> Display all 100 possibilities? (y or n)
>
> I guess adding one more option is no big deal, so go for it!
> We also have a couple --no-options already (as you said earlier),
> which I think makes it even more viable.
>
> Tangent:
> I wonder if we can cascade the completion by common
> prefixes, e.g. --no- or --ignore- occurs a couple of times,
> such that we could only show these --no- once and only
> if you try autocompleting thereafter you get all --no- options.
>
> Thanks for reviving this thread!
> Stefan
Stefan Beller· Nov 2, 2017, 21:19 UTC · re: Max Rothman · lore

Re: No log --no-decorate completion?

On Thu, Nov 2, 2017 at 1:25 PM, Max Rothman <max.r.rothman@gmail.com> wrote:
> No problem! Let me know if I've done something wrong with this patch,
> I'm new to git's contributor process.

Thanks for coming up with a patch! Yeah, the contribution process has some initial road blocks; I'll point them out below.

> completion: add missing completions for log, diff, show

I would think this is a good commit subject as it describes the changes made superficially

Show 5 quoted lines
> * Add bash completion for the missing --no-* options on git log
> * Add bash completion for --textconv and --indent-heuristic families to
>   git diff and all commands that use diff's options
> * Add bash completion for --no-abbrev-commit, --expand-tabs, and
>   --no-expand-tabs to git show

This describes what happens in this patch, but not why, which helps future readers of commit message more than the "what". I'm also just guessing but maybe:

    A user might have configured a repo to show diffs in a certain way,
    add the --no-* options to the autocompletion to override it easier
    from the command line.
    New in this patch is autocompletion for --textconv as well as abbreviation
    options as that needs to be flipped all the time in <example workflow>.

I wonder if we really want to expose indent-heuristic, I guess by not having it experimental any more it makes sense to do so. c.f. https://public-inbox.org/git/20171029151228.607834-1-cmn@dwim.me/

At the end of a commit message, the Git project requires a sign off. (See section (5) in Documentation/SubmittingPatches; tl;dr: add Signed-off-by: NAME <EMAIL> if you can agree to https://developercertificate.org/)

Show 67 quoted lines
> ---
>  contrib/completion/git-completion.bash | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash
> b/contrib/completion/git-completion.bash
> index 0e16f017a4144..252a6c8c0c80c 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1412,6 +1412,8 @@ __git_diff_common_options="--stat --numstat
> --shortstat --summary
>                         --dirstat-by-file= --cumulative
>                         --diff-algorithm=
>                         --submodule --submodule=
> +                       --indent-heuristic --no-indent-heuristic
> +                       --textconv --no-textconv
>  "
>
>  _git_diff ()
> @@ -1752,6 +1754,10 @@ _git_log ()
>                 __gitcomp "$__git_diff_submodule_formats" ""
> "${cur##--submodule=}"
>                 return
>                 ;;
> +       --no-walk=*)
> +               __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
> +               return
> +               ;;
>         --*)
>                 __gitcomp "
>                         $__git_log_common_options
> @@ -1759,16 +1765,19 @@ _git_log ()
>                         $__git_log_gitk_options
>                         --root --topo-order --date-order --reverse
>                         --follow --full-diff
> -                       --abbrev-commit --abbrev=
> +                       --abbrev-commit --no-abbrev-commit --abbrev=
>                         --relative-date --date=
>                         --pretty= --format= --oneline
>                         --show-signature
>                         --cherry-mark
>                         --cherry-pick
>                         --graph
> -                       --decorate --decorate=
> +                       --decorate --decorate= --no-decorate
>                         --walk-reflogs
> +                       --no-walk --no-walk= --do-walk
>                         --parents --children
> +                       --expand-tabs --expand-tabs= --no-expand-tabs
> +                       --patch
>                         $merge
>                         $__git_diff_common_options
>                         --pickaxe-all --pickaxe-regex
> @@ -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
>

The patch looks good, but doesn't apply because the email contains white spaces instead of tabs. Maybe try https://submitgit.herokuapp.com/ (or fix/change your email client to send a patch; the gmail web interface doesn't work. I personally got 'git send-email' up and running; The Documentation/SubmittingPatches has a section on email clients, too)

Thanks, Stefan

Max Rothman· Nov 7, 2017, 20:31 UTC · re: Stefan Beller · lore

Re: No log --no-decorate completion?

Thanks for the feedback!
Show 8 quoted lines
>> * Add bash completion for the missing --no-* options on git log
>> * Add bash completion for --textconv and --indent-heuristic families to
>>   git diff and all commands that use diff's options
>> * Add bash completion for --no-abbrev-commit, --expand-tabs, and
>>   --no-expand-tabs to git show
>
> This describes what happens in this patch, but not why, which helps
> future readers of commit message more than the "what".
How about:
Show 11 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.
> At the end of a commit message, the Git project requires a sign off.
> (See section (5) in Documentation/SubmittingPatches;
> tl;dr: add Signed-off-by: NAME <EMAIL> if you can agree to
> https://developercertificate.org/)

So the sign-off should include my name and email? I thought it was supposed to be the person who approved the patch, but I must've gotten confused.

Show 5 quoted lines
> The patch looks good, but doesn't apply because the email contains
> white spaces instead of tabs. Maybe try https://submitgit.herokuapp.com/
> (or fix/change your email client to send a patch; the gmail web interface
> doesn't work. I personally got 'git send-email' up and running;
> The Documentation/SubmittingPatches has a section on email clients, too)

Yeah, I was using the gmail interface. I'll give the heroku app a go. It has an option for sending a message in reply to another, and I assume I should send it in reply to this thread. Do you know how to tell what the appropriate ID to use is? Looking through the raw email, I see several, so it's not obvious to me which to use.

Thanks, Max

Stefan Beller· Nov 7, 2017, 20:48 UTC · re: Max Rothman · lore

Re: No log --no-decorate completion?

On Tue, Nov 7, 2017 at 12:31 PM, Max Rothman <max.r.rothman@gmail.com> wrote:
Show 24 quoted lines
> Thanks for the feedback!
>
>>> * Add bash completion for the missing --no-* options on git log
>>> * Add bash completion for --textconv and --indent-heuristic families to
>>>   git diff and all commands that use diff's options
>>> * Add bash completion for --no-abbrev-commit, --expand-tabs, and
>>>   --no-expand-tabs to git show
>>
>> This describes what happens in this patch, but not why, which helps
>> future readers of commit message more than the "what".
>
> How about:
>
>> 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.
Sounds good to me.
Show 8 quoted lines
>> At the end of a commit message, the Git project requires a sign off.
>> (See section (5) in Documentation/SubmittingPatches;
>> tl;dr: add Signed-off-by: NAME <EMAIL> if you can agree to
>> https://developercertificate.org/)
>
> So the sign-off should include my name and email? I thought it was
> supposed to be the person who approved the patch, but I must've gotten
> confused.

Anyone touching the patch needs to sign off on it. So when you write it, you sign off (thereby certifying that you are legally allowed to write the patch. For example you may be employed and the work contract requires you to not work on side projects, or the intellectual property belongs to the employer or such).

Hypothetically you could send it to Git-for-Windows which happens to be a fork of git. The maintainer of GfW would gladly accept your patch, (and also sign it off, thereby certifying he can touch it legally). Thereafter someone such as a regular contributor from the git project could spot the difference in GfW and git, and they would want to bring it to "the real git", so they would make a patch out of the commit in GfW. Additionally to the 2 sign offs, this contributor would also need to sign off on the patch, saying it is legal what they do. And then that patch could be picked up by the maintainer for the regular git. After that journey the patch would have 4 sign offs, indicating the way of travel, i.e. how it reached git finally.

An example of a longer sign off chain is 89dd32aedc (check-ref-format doc: --branch validates and expands <branch>, 2017-10-17) and apparently Jeff helped Junio to author a patch; Jonathan took that patch and changed a thing, only to send it back to Junio, who then applied it to git.

Show 11 quoted lines
>> The patch looks good, but doesn't apply because the email contains
>> white spaces instead of tabs. Maybe try https://submitgit.herokuapp.com/
>> (or fix/change your email client to send a patch; the gmail web interface
>> doesn't work. I personally got 'git send-email' up and running;
>> The Documentation/SubmittingPatches has a section on email clients, too)
>
> Yeah, I was using the gmail interface. I'll give the heroku app a go.
> It has an option for sending a message in reply to another, and I
> assume I should send it in reply to this thread. Do you know how to
> tell what the appropriate ID to use is? Looking through the raw email,
> I see several, so it's not obvious to me which to use.

In gmail, there is a "show original" in the menu near reply, which will show Message ID<CAFA_24L5nTUhO=PbMB9SdnCB1Lj+5rmOHmMJwkuLGWgy-ooxBA@mail.gmail.com> for the email that I am responding to.

Another way to explore the message ids is public-inbox, as that uses the message ids as keys, i.e.

  https://public-inbox.org/git/CAFA_24L5nTUhO=PbMB9SdnCB1Lj+5rmOHmMJwkuLGWgy-ooxBA@mail.gmail.com
is your email there.

Thanks, Stefan

Max Rothman· Nov 7, 2017, 21:22 UTC · re: Stefan Beller · lore

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

From: Max Rothman <max-rothman@pluralsight.com>

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.
---
 contrib/completion/git-completion.bash | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0e16f017a4144..252a6c8c0c80c 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1412,6 +1412,8 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
 			--dirstat-by-file= --cumulative
 			--diff-algorithm=
 			--submodule --submodule=
+			--indent-heuristic --no-indent-heuristic
+			--textconv --no-textconv
 "
 
 _git_diff ()
@@ -1752,6 +1754,10 @@ _git_log ()
 		__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
 		return
 		;;
+	--no-walk=*)
+		__gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
+		return
+		;;
 	--*)
 		__gitcomp "
 			$__git_log_common_options
@@ -1759,16 +1765,19 @@ _git_log ()
 			$__git_log_gitk_options
 			--root --topo-order --date-order --reverse
 			--follow --full-diff
-			--abbrev-commit --abbrev=
+			--abbrev-commit --no-abbrev-commit --abbrev=
 			--relative-date --date=
 			--pretty= --format= --oneline
 			--show-signature
 			--cherry-mark
 			--cherry-pick
 			--graph
-			--decorate --decorate=
+			--decorate --decorate= --no-decorate
 			--walk-reflogs
+			--no-walk --no-walk= --do-walk
 			--parents --children
+			--expand-tabs --expand-tabs= --no-expand-tabs
+			--patch
 			$merge
 			$__git_diff_common_options
 			--pickaxe-all --pickaxe-regex
@@ -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

--
https://github.com/git/git/pull/426
Junio C Hamano· Nov 8, 2017, 02:33 UTC · re: Max Rothman · lore

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

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.
Max Rothman· Nov 8, 2017, 03:30 UTC · re: Junio C Hamano · lore

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

Show 17 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.

My bad, that's still how they're named when using manpages, so that's what my muscle memory did.

Show 13 quoted lines
>
>  * 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?
How about this:

The bash completion script knows some options to "git log" and "git show" only in the positive form, (e.g. "--abbrev-commit"), but not in their negative form (e.g. "--no-abbrev-commit"). Adds them.

Also, the bash completion script is missing some other options to "git diff", and "git show" (and thus, all other commands that take "git diff"'s options). Adds them. Of note, since "--indent-heuristic" is no longer experimental, adds that too.

>
>> ---
>
> Missed sign-off?

Whoops, there doesn't seem to be a way to add that separately from the commit message in the submitGit interface. I'll try adding it, but gmail might turn all the tabs into spaces, so if it does, I'll try to figure out how to resubmit.

Show 37 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.

I think I'll stick with this patch for now (it's my first!), but I might come around and do refactoring in a second pass.

Thanks, Max

Junio C Hamano· Nov 8, 2017, 04:06 UTC · re: Max Rothman · lore

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

Max Rothman <max.r.rothman@gmail.com> writes:
Show 5 quoted lines
> How about this:
>
> The bash completion script knows some options to "git log" and
> "git show" only in the positive form, (e.g. "--abbrev-commit"), but not
> in their negative form (e.g. "--no-abbrev-commit"). Adds them.

s/Adds them/Add them/; we speak as if we are giving an order to the codebase to "become like so" (or to the patch monkey to "make the code so").

> Also, the bash completion script is missing some other options to
> "git diff", and "git show" (and thus, all other commands that take
> "git diff"'s options). Adds them. Of note, since "--indent-heuristic" is
> no longer experimental, adds that too.
Likewise for the two "adds".
Show 8 quoted lines
>>> ---
>>
>> Missed sign-off?
>
> Whoops, there doesn't seem to be a way to add that separately from the
> commit message in the submitGit interface. I'll try adding it, but
> gmail might turn all the tabs into spaces, so if it does, I'll try to
> figure out how to resubmit.

I would imagine that the cleanest way is to "commit --amend" and have submitGit see that updated/corrected copy.

Thanks.
Max Rothman· Jul 2, 2019, 01:56 UTC · re: Max Rothman · lore

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

The bash completion script knows some options to "git log" and "git show" only in the positive form, (e.g. "--abbrev-commit"), but not in their negative form (e.g. "--no-abbrev-commit"). Add them.

Also, the bash completion script is missing some other options to "git diff", and "git show" (and thus, all other commands that take "git diff"'s options). Add them. Of note, since "--indent-heuristic" is no longer experimental, add that too.

Signed-off-by: Max Rothman <max.r.rothman@gmail.com>
---
 contrib/completion/git-completion.bash | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9f71bcde967bc..b6d18710135ec 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1474,6 +1474,8 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
 			--dirstat-by-file= --cumulative
 			--diff-algorithm=
 			--submodule --submodule= --ignore-submodules
+			--indent-heuristic --no-indent-heuristic
+			--textconv --no-textconv
 "
 
 _git_diff ()
@@ -1782,6 +1784,10 @@ _git_log ()
 		__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
 		return
 		;;
+	--no-walk=*)
+		__gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
+		return
+		;;
 	--*)
 		__gitcomp "
 			$__git_log_common_options
@@ -1789,16 +1795,19 @@ _git_log ()
 			$__git_log_gitk_options
 			--root --topo-order --date-order --reverse
 			--follow --full-diff
-			--abbrev-commit --abbrev=
+			--abbrev-commit --no-abbrev-commit --abbrev=
 			--relative-date --date=
 			--pretty= --format= --oneline
 			--show-signature
 			--cherry-mark
 			--cherry-pick
 			--graph
-			--decorate --decorate=
+			--decorate --decorate= --no-decorate
 			--walk-reflogs
+			--no-walk --no-walk= --do-walk
 			--parents --children
+			--expand-tabs --expand-tabs= --no-expand-tabs
+			--patch
 			$merge
 			$__git_diff_common_options
 			--pickaxe-all --pickaxe-regex
@@ -2525,8 +2534,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

--
https://github.com/git/git/pull/426
Max Rothman· Aug 2, 2019, 00:54 UTC · re: Max Rothman · lore

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

Ping :)
On Thu, Aug 1, 2019 at 8:50 PM Max Rothman <max.r.rothman@gmail.com> wrote:
Show 77 quoted lines
>
> The bash completion script knows some options to "git log" and
> "git show" only in the positive form, (e.g. "--abbrev-commit"), but not
> in their negative form (e.g. "--no-abbrev-commit"). Add them.
>
> Also, the bash completion script is missing some other options to
> "git diff", and "git show" (and thus, all other commands that take
> "git diff"'s options). Add them. Of note, since "--indent-heuristic" is
> no longer experimental, add that too.
>
> Signed-off-by: Max Rothman <max.r.rothman@gmail.com>
> ---
>  contrib/completion/git-completion.bash | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 9f71bcde967bc..b6d18710135ec 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1474,6 +1474,8 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
>                         --dirstat-by-file= --cumulative
>                         --diff-algorithm=
>                         --submodule --submodule= --ignore-submodules
> +                       --indent-heuristic --no-indent-heuristic
> +                       --textconv --no-textconv
>  "
>
>  _git_diff ()
> @@ -1782,6 +1784,10 @@ _git_log ()
>                 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
>                 return
>                 ;;
> +       --no-walk=*)
> +               __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
> +               return
> +               ;;
>         --*)
>                 __gitcomp "
>                         $__git_log_common_options
> @@ -1789,16 +1795,19 @@ _git_log ()
>                         $__git_log_gitk_options
>                         --root --topo-order --date-order --reverse
>                         --follow --full-diff
> -                       --abbrev-commit --abbrev=
> +                       --abbrev-commit --no-abbrev-commit --abbrev=
>                         --relative-date --date=
>                         --pretty= --format= --oneline
>                         --show-signature
>                         --cherry-mark
>                         --cherry-pick
>                         --graph
> -                       --decorate --decorate=
> +                       --decorate --decorate= --no-decorate
>                         --walk-reflogs
> +                       --no-walk --no-walk= --do-walk
>                         --parents --children
> +                       --expand-tabs --expand-tabs= --no-expand-tabs
> +                       --patch
>                         $merge
>                         $__git_diff_common_options
>                         --pickaxe-all --pickaxe-regex
> @@ -2525,8 +2534,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
>
> --
> https://github.com/git/git/pull/426
>
Max Rothman· Sep 11, 2019, 18:15 UTC · re: Max Rothman · lore

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

Just pinging again, I'd love to move this forward!
On Thu, Aug 1, 2019 at 8:54 PM Max Rothman <max.r.rothman@gmail.com> wrote:
Show 82 quoted lines
>
> Ping :)
>
>
> On Thu, Aug 1, 2019 at 8:50 PM Max Rothman <max.r.rothman@gmail.com> wrote:
> >
> > The bash completion script knows some options to "git log" and
> > "git show" only in the positive form, (e.g. "--abbrev-commit"), but not
> > in their negative form (e.g. "--no-abbrev-commit"). Add them.
> >
> > Also, the bash completion script is missing some other options to
> > "git diff", and "git show" (and thus, all other commands that take
> > "git diff"'s options). Add them. Of note, since "--indent-heuristic" is
> > no longer experimental, add that too.
> >
> > Signed-off-by: Max Rothman <max.r.rothman@gmail.com>
> > ---
> >  contrib/completion/git-completion.bash | 18 ++++++++++++++----
> >  1 file changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> > index 9f71bcde967bc..b6d18710135ec 100644
> > --- a/contrib/completion/git-completion.bash
> > +++ b/contrib/completion/git-completion.bash
> > @@ -1474,6 +1474,8 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
> >                         --dirstat-by-file= --cumulative
> >                         --diff-algorithm=
> >                         --submodule --submodule= --ignore-submodules
> > +                       --indent-heuristic --no-indent-heuristic
> > +                       --textconv --no-textconv
> >  "
> >
> >  _git_diff ()
> > @@ -1782,6 +1784,10 @@ _git_log ()
> >                 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
> >                 return
> >                 ;;
> > +       --no-walk=*)
> > +               __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
> > +               return
> > +               ;;
> >         --*)
> >                 __gitcomp "
> >                         $__git_log_common_options
> > @@ -1789,16 +1795,19 @@ _git_log ()
> >                         $__git_log_gitk_options
> >                         --root --topo-order --date-order --reverse
> >                         --follow --full-diff
> > -                       --abbrev-commit --abbrev=
> > +                       --abbrev-commit --no-abbrev-commit --abbrev=
> >                         --relative-date --date=
> >                         --pretty= --format= --oneline
> >                         --show-signature
> >                         --cherry-mark
> >                         --cherry-pick
> >                         --graph
> > -                       --decorate --decorate=
> > +                       --decorate --decorate= --no-decorate
> >                         --walk-reflogs
> > +                       --no-walk --no-walk= --do-walk
> >                         --parents --children
> > +                       --expand-tabs --expand-tabs= --no-expand-tabs
> > +                       --patch
> >                         $merge
> >                         $__git_diff_common_options
> >                         --pickaxe-all --pickaxe-regex
> > @@ -2525,8 +2534,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
> >
> > --
> > https://github.com/git/git/pull/426
> >
Johannes Schindelin· Sep 12, 2019, 08:54 UTC · re: Max Rothman · lore

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

Hi Max,
The patch looks good to me!

Thanks, Johannes

On Wed, 11 Sep 2019, Max Rothman wrote:
Show 81 quoted lines
> On Thu, Aug 1, 2019 at 8:54 PM Max Rothman <max.r.rothman@gmail.com> wrote:
> >
> > On Thu, Aug 1, 2019 at 8:50 PM Max Rothman <max.r.rothman@gmail.com> wrote:
> > >
> > > The bash completion script knows some options to "git log" and
> > > "git show" only in the positive form, (e.g. "--abbrev-commit"), but not
> > > in their negative form (e.g. "--no-abbrev-commit"). Add them.
> > >
> > > Also, the bash completion script is missing some other options to
> > > "git diff", and "git show" (and thus, all other commands that take
> > > "git diff"'s options). Add them. Of note, since "--indent-heuristic" is
> > > no longer experimental, add that too.
> > >
> > > Signed-off-by: Max Rothman <max.r.rothman@gmail.com>
> > > ---
> > >  contrib/completion/git-completion.bash | 18 ++++++++++++++----
> > >  1 file changed, 14 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> > > index 9f71bcde967bc..b6d18710135ec 100644
> > > --- a/contrib/completion/git-completion.bash
> > > +++ b/contrib/completion/git-completion.bash
> > > @@ -1474,6 +1474,8 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
> > >                         --dirstat-by-file= --cumulative
> > >                         --diff-algorithm=
> > >                         --submodule --submodule= --ignore-submodules
> > > +                       --indent-heuristic --no-indent-heuristic
> > > +                       --textconv --no-textconv
> > >  "
> > >
> > >  _git_diff ()
> > > @@ -1782,6 +1784,10 @@ _git_log ()
> > >                 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
> > >                 return
> > >                 ;;
> > > +       --no-walk=*)
> > > +               __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
> > > +               return
> > > +               ;;
> > >         --*)
> > >                 __gitcomp "
> > >                         $__git_log_common_options
> > > @@ -1789,16 +1795,19 @@ _git_log ()
> > >                         $__git_log_gitk_options
> > >                         --root --topo-order --date-order --reverse
> > >                         --follow --full-diff
> > > -                       --abbrev-commit --abbrev=
> > > +                       --abbrev-commit --no-abbrev-commit --abbrev=
> > >                         --relative-date --date=
> > >                         --pretty= --format= --oneline
> > >                         --show-signature
> > >                         --cherry-mark
> > >                         --cherry-pick
> > >                         --graph
> > > -                       --decorate --decorate=
> > > +                       --decorate --decorate= --no-decorate
> > >                         --walk-reflogs
> > > +                       --no-walk --no-walk= --do-walk
> > >                         --parents --children
> > > +                       --expand-tabs --expand-tabs= --no-expand-tabs
> > > +                       --patch
> > >                         $merge
> > >                         $__git_diff_common_options
> > >                         --pickaxe-all --pickaxe-regex
> > > @@ -2525,8 +2534,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
> > >
> > > --
> > > https://github.com/git/git/pull/426
> > >
>
Johannes Schindelin· Sep 13, 2019, 21:03 UTC · lore

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

Hi Max,

[your reply did not make it to the Git mailing list because it drops anything with an HTML part]

On Thu, 12 Sep 2019, Max Rothman wrote:
> Great! What’s the path for getting this merged?

Usually it will be picked up into the `pu` branch first, then advance to `next`, and then to `master`. Once it is in `master`, it will be part of the then-next official version ending in `.0`.

You can also read about the state of your patch (once it has been picked up) in the bi-weekly "What's cooking" mails. If you're not subscribed, you can look at the current version on the web: https://github.com/git/git/blob/todo/whats-cooking.txt

Ciao, Johannes

Show 105 quoted lines
>
> On Thu, Sep 12, 2019 at 4:54 AM Johannes Schindelin <
> Johannes.Schindelin@gmx.de> wrote:
>
> > Hi Max,
> >
> > The patch looks good to me!
> >
> > Thanks,
> > Johannes
> >
> > On Wed, 11 Sep 2019, Max Rothman wrote:
> >
> > > On Thu, Aug 1, 2019 at 8:54 PM Max Rothman <max.r.rothman@gmail.com>
> > wrote:
> > > >
> > > > On Thu, Aug 1, 2019 at 8:50 PM Max Rothman <max.r.rothman@gmail.com>
> > wrote:
> > > > >
> > > > > The bash completion script knows some options to "git log" and
> > > > > "git show" only in the positive form, (e.g. "--abbrev-commit"), but
> > not
> > > > > in their negative form (e.g. "--no-abbrev-commit"). Add them.
> > > > >
> > > > > Also, the bash completion script is missing some other options to
> > > > > "git diff", and "git show" (and thus, all other commands that take
> > > > > "git diff"'s options). Add them. Of note, since "--indent-heuristic"
> > is
> > > > > no longer experimental, add that too.
> > > > >
> > > > > Signed-off-by: Max Rothman <max.r.rothman@gmail.com>
> > > > > ---
> > > > >  contrib/completion/git-completion.bash | 18 ++++++++++++++----
> > > > >  1 file changed, 14 insertions(+), 4 deletions(-)
> > > > >
> > > > > diff --git a/contrib/completion/git-completion.bash
> > b/contrib/completion/git-completion.bash
> > > > > index 9f71bcde967bc..b6d18710135ec 100644
> > > > > --- a/contrib/completion/git-completion.bash
> > > > > +++ b/contrib/completion/git-completion.bash
> > > > > @@ -1474,6 +1474,8 @@ __git_diff_common_options="--stat --numstat
> > --shortstat --summary
> > > > >                         --dirstat-by-file= --cumulative
> > > > >                         --diff-algorithm=
> > > > >                         --submodule --submodule= --ignore-submodules
> > > > > +                       --indent-heuristic --no-indent-heuristic
> > > > > +                       --textconv --no-textconv
> > > > >  "
> > > > >
> > > > >  _git_diff ()
> > > > > @@ -1782,6 +1784,10 @@ _git_log ()
> > > > >                 __gitcomp "$__git_diff_submodule_formats" ""
> > "${cur##--submodule=}"
> > > > >                 return
> > > > >                 ;;
> > > > > +       --no-walk=*)
> > > > > +               __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
> > > > > +               return
> > > > > +               ;;
> > > > >         --*)
> > > > >                 __gitcomp "
> > > > >                         $__git_log_common_options
> > > > > @@ -1789,16 +1795,19 @@ _git_log ()
> > > > >                         $__git_log_gitk_options
> > > > >                         --root --topo-order --date-order --reverse
> > > > >                         --follow --full-diff
> > > > > -                       --abbrev-commit --abbrev=
> > > > > +                       --abbrev-commit --no-abbrev-commit --abbrev=
> > > > >                         --relative-date --date=
> > > > >                         --pretty= --format= --oneline
> > > > >                         --show-signature
> > > > >                         --cherry-mark
> > > > >                         --cherry-pick
> > > > >                         --graph
> > > > > -                       --decorate --decorate=
> > > > > +                       --decorate --decorate= --no-decorate
> > > > >                         --walk-reflogs
> > > > > +                       --no-walk --no-walk= --do-walk
> > > > >                         --parents --children
> > > > > +                       --expand-tabs --expand-tabs= --no-expand-tabs
> > > > > +                       --patch
> > > > >                         $merge
> > > > >                         $__git_diff_common_options
> > > > >                         --pickaxe-all --pickaxe-regex
> > > > > @@ -2525,8 +2534,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
> > > > >
> > > > > --
> > > > > https://github.com/git/git/pull/426
> > > > >
> > >
> >
>

← back to recent threads