How Do You Get the bufspec While Using Vimdiff Through Git
- by Elizabeth Buckwalter
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?