Skip to content
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

git blame: configurable additional options #400

Closed
wookayin opened this issue Nov 7, 2021 · 2 comments · Fixed by #406
Closed

git blame: configurable additional options #400

wookayin opened this issue Nov 7, 2021 · 2 comments · Fixed by #406
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@wookayin
Copy link
Contributor

wookayin commented Nov 7, 2021

Is your feature request related to a problem? Please describe.

Please allow extra arguments for git blame (for lua require"gitsigns".blame_line(true), for example). For example, git blame -w is a very commonly used command to ignore whitespace changes.

Describe the solution you'd like

We could have some configurations like

gitsigns.setup {
   ...
   extra_blame_args = '-w',          -- default is '' (empty)
}

or the field name as you wish.

Alternativelty, allow additional opts:

gitsigns.blame_line(true, {extra_args = '-w'})

(BTW the first argument full could be a part of the opts as well)

Describe alternatives you've considered

N/A

Additional context

I checked the implementation lua/gitsigns/git.lua and there is currently no such feature implemented. For example, git-messenger has this feature via let g:git_messenger_extra_blame_args.

@wookayin wookayin added the enhancement New feature or request label Nov 7, 2021
@lewis6991
Copy link
Owner

lewis6991 commented Nov 10, 2021

The fact that Gitsigns uses the git cli is just an implementation detail and not foundational to the overall design. If lua-git ever becomes production ready, we would plan to use that where possible.

So with that said, exposing configuration to append options on to specific git commands doesn't seem like the best idea. Git blame doesn't have a huge amount of options, so first class support for the features we want will be ok. From what I can tell, -w and -M seem like the only useful options.

I propose we add additional options to blame_line (and maybe mirror that to current_line_blame), to be something like:

blame_line({opts})                                     *gitsigns.blame_line()*

                Parameters: ~
                    {opts}   (table|nil):
                             Additional options:
                             • {full}: (boolean)
                               Display the full commit message.
                             • {ignore_whitespace}: (boolean)
                               Ignore whitespace when comparing the parent’s
                               version and the child’s to find where the lines 
                               came from.

For backwards compat, blame_line(true) would become an alias for blame_line{full=true}.

@lewis6991 lewis6991 added the good first issue Good for newcomers label Nov 10, 2021
@wookayin
Copy link
Contributor Author

I totally agree with you about the abstraction. Adding ignore_whitespace only also sounds great to me, and it's also open to extension.

lewis6991 added a commit that referenced this issue Nov 16, 2021
- blame_line() now takes a table as it's first argument (instead of a
boolean) with the fields "full" and "ignore_whitespace"

- Added config.current_line_blame_opts.ignore_whitespace

Resolves #400
lewis6991 added a commit that referenced this issue Nov 16, 2021
- blame_line() now takes a table as it's first argument (instead of a
boolean) with the fields "full" and "ignore_whitespace"

- Added config.current_line_blame_opts.ignore_whitespace

Resolves #400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
2 participants