How Do You Get the bufspec While Using Vimdiff Through Git

Posted by Elizabeth Buckwalter on Stack Overflow See other posts from Stack Overflow or by Elizabeth Buckwalter
Published on 2010-03-24T18:51:20Z Indexed on 2010/03/26 17:43 UTC
Read the original article Hit count: 502

Filed under:
|
|

I've read Vimdiff and Viewing differences with Vimdiff plus doing various google searches using things like "vimdiff multiple", "vimdiff git", "vimdiff commands" etc.

When using do or diffg I get the error "More than two buffers in diff mode, don't know which one to use".

When using diffg v:fname_in I get "No matching buffer for v:fname_in".

From the vimdiff documentation:

:[range]diffg[et] [bufspec]
Modify the current buffer to undo difference with another buffer. If [bufspec] is given, that buffer is used. If [bufspec] refers to the current buffer then nothing happens. Otherwise this only works if there is one other buffer in diff mode.

and more:

When 'diffexpr' is not empty, Vim evaluates to obtain a diff file in the format mentioned. These variables are set to the file names used:

v:fname_in original file
v:fname_new new version of the same file
v:fname_out resulting diff file

So, I need to get the name of bufspec, but the default variables (fname_in, fname_new, and fname_out) aren't set.

I ran the command git mergetool on a linux box through a terminal.

[Edit] A partial solution that bred more questions. I used the "filename" at the bottom of the buffer. It's only a half answer, because occasionally I get a file does not exist error. I believe it's consistently the remote version of the file that "does not exist". I suspect this has something to do with git and indexing.

How do you get the bufspec value consistently while using vimdiff through git-mergetool?

© Stack Overflow or respective owner

Related posts about git-merge

Related posts about vimdiff