4

I have the following configuration in my ~/.gitconfig

[diff]
    tool = vimdiff
[diftool]
    prompt = false

When I launch git difftool it opens up the buffers in read-only mode by default. I use it to review the changes before a commit and say I find some small change like a commented out line I have not removed or a JS console.log statement, I am forced to quit the tool and open the file and make the change. I would very much like a way to do the change within the visual diff window itself.

http://gitlog.wordpress.com/2011/03/30/git-1-7-4-2/ says that "“git difftool” didn’t tell (g)vimdiff that the files it is reading are to be opened read-only." From this I figure that this read-only behavior was desired.

  1. I am curious to know why having a read-only behavior in difftool was chosen as the default.

  2. Is there any way I can configure the difftool to allow read/write?

  3. From git, vimdiff and dirdiff, I see that fugitive plugin for vim and git diffall script are also available as alternatives to make this diff reviewing process easier. Will using fugitive open up the possibility of using a read/write visual diff mode?

Community
  • 1
  • 1
Ramnath
  • 67
  • 6

2 Answers2

8

If you aren't using fugitive, you can toggle read-only mode (per pane!) with

:set readonly!

or

:set ro!
djeikyb
  • 4,470
  • 3
  • 35
  • 42
4

Fugitive will allow you to change the working copy file while diffing. Just run :Gdiff and a vertical split with the index version will appear. Now you can :diffput (or short dp) inside the working copy to put the chunk into the index file, or alternatively, :diffget (or short do) from the index file to get the chunk from the working copy. Once you have everything in the index file that you want, save it, and that will now be your stashed version.

What really helped me understand the process were the vimcasts #31 to #35 about Fugitive.vim:
http://vimcasts.org/episodes/archive

fphilipe
  • 9,739
  • 1
  • 40
  • 52