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
Only pass revision argument to diff command when required #70
Conversation
@blueyed There you go. This code is a bit cleaner than what I did this morning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I prefer this approach. Would you be willing to make the suggested changes? Thanks!
@@ -573,6 +555,33 @@ function! s:GetParam(name, type, default) abort "{{{3 | |||
endf | |||
|
|||
|
|||
function! s:Diff(filename, vcs_type) "{{{3 | |||
let cmdt = s:Config(a:vcs_type).cmd | |||
let rev_arg = s:GetParam('quickfixsigns#vcsdiff#rev_arg', a:vcs_type, s:Config(a:vcs_type).rev_arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rev_arg isn't a (user-configurable) "parameter" but a fixed value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that I should do this?
let rev_arg = s:Config(a:vcs_type).rev_arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
|
||
" Create command string | ||
let cmds = printf("%s %s", g:quickfixsigns#vcsdiff#cd, shellescape(dir)) | ||
if exists('g:quickfixsigns#vcsdiff#revision') && !empty('g:quickfixsigns#vcsdiff#revision') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g:quickfixsigns#vcsdiff#revision should be queried as user-configurable parameter.
I'd rather set revision to the formatted revision argument if a revision is specified or an empty string if no rev is specified. This makes the code duplication in the else branch obsolete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea!
@@ -437,7 +437,7 @@ g:quickfixsigns#vcsdiff#vcs (default: {...}) | |||
cmd ... command templates that generate a unified diff file. | |||
"%s" is replaced with the filename. | |||
dir ... the directory name | |||
revision ... The default revision/branch | |||
rev_arg ... argument to selection revision to diff against |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the help file. The help file is auto-generated from time to time so it's not absolutely necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you use for that purpose? I could benefit from such a flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use this ruby script: https://github.com/tomtom/vimtlib/tree/master/ruby
It was a quick hack, and it isn't well maintained, though.
Move common diff generation code to local script function.
Updated. |
Thanks!
|
Thank you for your helpful suggestions! |
Thanks to both of you from me! :) |
Move common diff generation code to local script function.