New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add completions for git blame command #3094

Merged
merged 1 commit into from Jun 2, 2016

Conversation

Projects
None yet
4 participants
@Hunsu
Contributor

Hunsu commented May 31, 2016

I would like to know how to test it.

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho May 31, 2016

Member

Thanks for doing this!

I would like to know how to test it.

You copy the file into a directory in $fish_complete_path, e.g. ~/.config/fish/completions, and then just use it.

I'm gonna add some more comments inline.

Member

faho commented May 31, 2016

Thanks for doing this!

I would like to know how to test it.

You copy the file into a directory in $fish_complete_path, e.g. ~/.config/fish/completions, and then just use it.

I'm gonna add some more comments inline.

Show outdated Hide outdated share/completions/git.fish
complete -f -c git -n '__fish_git_needs_command' -a blame -d 'Show what revision and author last modified each line of a file'
complete -f -c git -n '__fish_git_using_command blame' -s b -d 'Show blank SHA-1 for boundary commits'
complete -f -c git -n '__fish_git_using_command blame' -l root -d 'Do not treat root commits as boundaries'
complete -f -c git -n '__fish_git_using_command blame' -l show-stats -d 'Include additional statistics at the end of blame output'

This comment has been minimized.

@faho

faho May 31, 2016

Member

The "of blame output" is a bit redundant.

@faho

faho May 31, 2016

Member

The "of blame output" is a bit redundant.

Show outdated Hide outdated share/completions/git.fish
complete -f -c git -n '__fish_git_using_command blame' -s L -d 'Annotate only the given line range'
complete -f -c git -n '__fish_git_using_command blame' -s l -d 'Show long rev'
complete -f -c git -n '__fish_git_using_command blame' -s t -d 'Show raw timestamp'
complete -f -c git -n '__fish_git_using_command blame' -s S -d 'Use revisions from revs-file instead of calling git-rev-list'

This comment has been minimized.

@faho

faho May 31, 2016

Member

This needs a file as argument, that's the "revs-file". How about "Use revisions from named file instead of calling rev-list"?

@faho

faho May 31, 2016

Member

This needs a file as argument, that's the "revs-file". How about "Use revisions from named file instead of calling rev-list"?

Show outdated Hide outdated share/completions/git.fish
complete -f -c git -n '__fish_git_using_command blame' -s p -l porcelain -d 'Show in a format designed for machine consumption'
complete -f -c git -n '__fish_git_using_command blame' -l line-porcelain -d 'Show the porcelain format'
complete -f -c git -n '__fish_git_using_command blame' -l incremental -d 'Show the result incrementally'
complete -f -c git -n '__fish_git_using_command blame' -l encoding -d 'Specifies the encoding'

This comment has been minimized.

@faho

faho May 31, 2016

Member

This needs an encoding. I'm not sure how git expects these - does "--encoding=utf-8" work, or does it need to be upper case? Anyway, this is shared with log at least so it should be in the shared options section (added recently).

@faho

faho May 31, 2016

Member

This needs an encoding. I'm not sure how git expects these - does "--encoding=utf-8" work, or does it need to be upper case? Anyway, this is shared with log at least so it should be in the shared options section (added recently).

Show outdated Hide outdated share/completions/git.fish
complete -f -c git -n '__fish_git_using_command blame' -l line-porcelain -d 'Show the porcelain format'
complete -f -c git -n '__fish_git_using_command blame' -l incremental -d 'Show the result incrementally'
complete -f -c git -n '__fish_git_using_command blame' -l encoding -d 'Specifies the encoding'
complete -f -c git -n '__fish_git_using_command blame' -l contents -d 'Annotates the changes starting backwards from the working tree copy'

This comment has been minimized.

@faho

faho May 31, 2016

Member

I think you've stopped reading too early. From the man page:

This flag makes the command pretend as if the working tree copy has the contents of the named file

So something like "Instead of working tree, use the contents of the named file"?

@faho

faho May 31, 2016

Member

I think you've stopped reading too early. From the man page:

This flag makes the command pretend as if the working tree copy has the contents of the named file

So something like "Instead of working tree, use the contents of the named file"?

Show outdated Hide outdated share/completions/git.fish
complete -f -c git -n '__fish_git_using_command blame' -s n -l show-number -d 'Show the line number in the original commit'
complete -f -c git -n '__fish_git_using_command blame' -s s -d 'Suppress the author name and timestamp from the output'
complete -f -c git -n '__fish_git_using_command blame' -s e -l show-email -d 'Show the author email instead of author name'
complete -f -c git -n '__fish_git_using_command blame' -s w -d 'Ignore whitespace when comparing the parent’s version and the child’s to find where the lines came from'

This comment has been minimized.

@faho

faho May 31, 2016

Member

Just "Ignore whitespace changes" should be enough. Keeping descriptions short allows us to use more columns. In general you probably want to paraphrase what the git man pages say as they have a rather... special style.

@faho

faho May 31, 2016

Member

Just "Ignore whitespace changes" should be enough. Keeping descriptions short allows us to use more columns. In general you probably want to paraphrase what the git man pages say as they have a rather... special style.

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho May 31, 2016

Member

For all the options that take a file, you'll want to replace the "-f" with a "-r" - they require an argument, and it can be a file - see complete --help.

These are "-S" and "--contents", for "--date" you'll probably want "-x" (no files but a required argument). Though that's another shared option (with git log again).

Member

faho commented May 31, 2016

For all the options that take a file, you'll want to replace the "-f" with a "-r" - they require an argument, and it can be a file - see complete --help.

These are "-S" and "--contents", for "--date" you'll probably want "-x" (no files but a required argument). Though that's another shared option (with git log again).

@faho faho self-assigned this May 31, 2016

@faho faho added the completions label May 31, 2016

@Hunsu

This comment has been minimized.

Show comment
Hide comment
@Hunsu

Hunsu May 31, 2016

Contributor

You copy the file into a directory in $fish_complete_path, e.g. ~/.config/fish/completions, and then just use it.

That's what I did but I got an error about string not recognized.

I'm gonna add some more comments inline.

Thanks, I will fix the issues.

Contributor

Hunsu commented May 31, 2016

You copy the file into a directory in $fish_complete_path, e.g. ~/.config/fish/completions, and then just use it.

That's what I did but I got an error about string not recognized.

I'm gonna add some more comments inline.

Thanks, I will fix the issues.

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho May 31, 2016

Member

That's what I dif but I got an error about string not recognized.

You're using completions from 2.3.0 but a fish before that. The string builtin is new in 2.3.0, so you'll want to upgrade to that.

Member

faho commented May 31, 2016

That's what I dif but I got an error about string not recognized.

You're using completions from 2.3.0 but a fish before that. The string builtin is new in 2.3.0, so you'll want to upgrade to that.

@faho faho merged commit 24d6f6d into fish-shell:master Jun 2, 2016

1 check failed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Jun 2, 2016

Member

Merged, thanks!

We probably want to add some more stuff here, but as a first pass it's not bad.

Member

faho commented Jun 2, 2016

Merged, thanks!

We probably want to add some more stuff here, but as a first pass it's not bad.

@Hunsu

This comment has been minimized.

Show comment
Hide comment
@Hunsu

Hunsu Jun 2, 2016

Contributor

We probably want to add some more stuff here, but as a first pass it's not bad.

What more stuff do you want to add? I will look at the TODO to improve the completions for git. I read somewhere that fish shell's auto-completion uses man pages, is it true? If so why it doesn't work for git (or the other commands).

Contributor

Hunsu commented Jun 2, 2016

We probably want to add some more stuff here, but as a first pass it's not bad.

What more stuff do you want to add? I will look at the TODO to improve the completions for git. I read somewhere that fish shell's auto-completion uses man pages, is it true? If so why it doesn't work for git (or the other commands).

@faho

This comment has been minimized.

Show comment
Hide comment
@faho

faho Jun 2, 2016

Member

I read somewhere that fish shell's auto-completion uses man pages, is it true?

You possibly read it on fishshell.com - it is true. We have a python script that tries to parse man pages and generate completion scripts from that. For simple stuff (commands that take files and only have long and short options that don't take arguments) it works, but for something like git man pages just aren't written in a precise enough format that it could do much. Even for simple stuff the descriptions are often "Something something something...[See the man page for details]".

So we have a lot of hand-written completions, which includes git (as you've probably seen).

What more stuff do you want to add?

Well, the arguments. From the man page, it appears git blame takes a "rev" and also files. We're not currently completing the "rev" part (which, in simplified terms, is a git-ism for those commit hashes you see all over the place).

Then we have the options that take arguments we're not completing yet, like "--encoding". We're also not yet sharing the shared options.

This is complicated stuff, and some of it might well be impossible with our current system - e.g. completing "dates", because there's an infinite number of them.

Member

faho commented Jun 2, 2016

I read somewhere that fish shell's auto-completion uses man pages, is it true?

You possibly read it on fishshell.com - it is true. We have a python script that tries to parse man pages and generate completion scripts from that. For simple stuff (commands that take files and only have long and short options that don't take arguments) it works, but for something like git man pages just aren't written in a precise enough format that it could do much. Even for simple stuff the descriptions are often "Something something something...[See the man page for details]".

So we have a lot of hand-written completions, which includes git (as you've probably seen).

What more stuff do you want to add?

Well, the arguments. From the man page, it appears git blame takes a "rev" and also files. We're not currently completing the "rev" part (which, in simplified terms, is a git-ism for those commit hashes you see all over the place).

Then we have the options that take arguments we're not completing yet, like "--encoding". We're also not yet sharing the shared options.

This is complicated stuff, and some of it might well be impossible with our current system - e.g. completing "dates", because there's an infinite number of them.

@zanchey zanchey added this to the next-2.x milestone Jun 6, 2016

@krader1961 krader1961 modified the milestones: fish 2.3.1, next-2.x Sep 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment