vim-fugitive icon indicating copy to clipboard operation
vim-fugitive copied to clipboard

Change flags given to show when viewing commit

Open SevereOverfl0w opened this issue 7 years ago • 6 comments
trafficstars

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_

SevereOverfl0w avatar Oct 08 '18 14:10 SevereOverfl0w

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 avatar Aug 18 '19 20:08 tpope

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

tpope avatar Aug 18 '19 20:08 tpope

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 avatar Dec 10 '20 19:12 nerdrew

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 avatar Dec 10 '20 22:12 nerdrew

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).

nerdrew avatar Dec 10 '20 22:12 nerdrew

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.

tpope avatar Mar 14 '21 07:03 tpope