tpope / vim-fugitive

fugitive.vim: A Git wrapper so awesome, it should be illegal
https://www.vim.org/scripts/script.php?script_id=2975
20.1k stars 1.01k forks source link

Change flags given to show when viewing commit #1109

Open SevereOverfl0w opened 6 years ago

SevereOverfl0w commented 6 years ago

This would allow me to add -w to ignore whitespace changes in git show. This can make many changes in Clojure where a top level function call was made, much easier to read.

One idea might be that this is another format type that commit has, and is just simply built in. Another is that users can alter the array at any time. Another would be that I call a public interface to s:ReplaceCmd directly.

Do you have a preferred way that an implementation to allow me to achieve an ignoring whitespace commit object?


For now, I am using this patch:

diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
index b5350d6..696bf41 100644
--- a/autoload/fugitive.vim
+++ b/autoload/fugitive.vim
@@ -1489,7 +1489,7 @@ function! fugitive#BufReadCmd(...) abort
         if b:fugitive_display_format
           call s:ReplaceCmd([dir, 'cat-file', b:fugitive_type, rev])
         else
-          call s:ReplaceCmd([dir, 'show', '--no-color', '--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b', rev])
+          call s:ReplaceCmd([dir, 'show', '--no-color', '-w', '--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b', rev])
           keepjumps call search('^parent ')
           if getline('.') ==# 'parent '
             silent keepjumps delete_
tpope commented 5 years ago

Not sure that making this configurable is the way to go. But let's start by enumerating what options people would want to set. -w and --word-diff seem like the biggies. What else?

tpope commented 5 years ago

Note you can do :Git show -w ! to get a one off display of the current commit.

nerdrew commented 3 years ago

Any movement on this? I just added https://github.com/nerdrew/vim-fugitive/commit/8076b298afea9c828e9fc9fb545708a57a511d57 to my fork to see if it does what I want.

nerdrew commented 3 years ago

One issue so far: when ignoring whitespace, you can't stage the diff. To stage the diff, I need to un-ignore whitespace again.

nerdrew commented 3 years ago

I added a similar toggle for --word-diff, but the output is different, so it doesn't show any diff (presumable because the diffs don't have + or - in the first column).

tpope commented 3 years ago

One issue so far: when ignoring whitespace, you can't stage the diff. To stage the diff, I need to un-ignore whitespace again.

The original request was for viewing a commit. Changing it in the status buffer is a non-starter for this reason alone.

Unless of course you find some way to cross reference the line numbers in the vanilla diff and the cosmetically altered diff and make it work anyways. But I'm going to work under the assumption that's impossible until proven otherwise.