Skip to content

Commit

Permalink
Allow using the "%" variable in git commands
Browse files Browse the repository at this point in the history
Closes #686

For example, when running:

  :Git add %

neovim throws the following exception:

  E499: Empty file name for '%' or '#',
  only works with ":p:h": terminal git add %

It is a result of the tabnew command, it creates a new blank tab where
"%" is empty.

This commit changes "tabnew" to "tabedit %" so you're still working on
the same file.

Once the command is done running the tab closes.
  • Loading branch information
elentok authored and tpope committed Sep 10, 2015
1 parent b319b69 commit b7b2300
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugin/fugitive.vim
Expand Up @@ -683,7 +683,7 @@ function! s:Git(bang, args) abort
let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
if exists(':terminal')
let dir = s:repo().tree()
tabnew
tabedit %
execute 'lcd' fnameescape(dir)
execute 'terminal' git args
else
Expand Down

1 comment on commit b7b2300

@assaf758
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still getting similar issue when running "Git status" (or any other Git command).
Using latest vim-fugitive.

Error detected while processing function <SNR>44_Git:                                                                                                                                                                                                                                       
line   11:                                                                                                                                                                                                                                                                                  
E499: Empty file name for '%' or '#', only works with ":p:h":     tabedit %    

Please sign in to comment.