Glog command gives "Permission denied" errors #199

savpek opened this Issue May 6, 2012 · 7 comments


None yet
4 participants

savpek commented May 6, 2012


Have problem with Fugitive (windows 7, Gvim, Msysgit 1.7xx). Everything else works fine, but Glog command cannot show log items and prints folder + Permission denied on every log item. heres error message. I am just thinking that may that very incorrect folder format cause problem?

My current setup can be downloaded from: It should be standalone, haven't tested it at other computers yet though.

savpek commented May 6, 2012

One more thing, running that command usually cause Fugitive crash out from Vim (None of fugitive commands are regoniced after that at Vim).


daisuzu commented Jun 4, 2012

Is it cause from 1b6c0cb ?

"Permission denied" may caused by Windows's UAC.
But folder format problem is caused by % interpretation.

Because % in string of git command is interpreted as current file path after escaping by s:shellesc().

Unescape the % in s:Log() like below, and :Glog is working well.
let &grepprg = substitute(call(s:repo().git_command,cmd,s:repo()), '"%"', '\%', 'g')

But this fix is too extemporaneously.
How should it fix this problem?

rxwen commented Jun 5, 2012

Is it feasible to update the s:shellesc function as following?

diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
old mode 100644
new mode 100755
index 5853526..1929df8
--- a/plugin/fugitive.vim
+++ b/plugin/fugitive.vim
@@ -30,7 +30,7 @@ function! s:shellesc(arg) abort
   if a:arg =~ '^[A-Za-z0-9_/.-]\+$'
     return a:arg
   elseif &shell =~# 'cmd'
-    return '"'.s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"').'"'
+    return '"'.s:gsub(a:arg, '"', '""').'"'
     return shellescape(a:arg)

daisuzu commented Jun 5, 2012

This patch can fix the :Glog problem.

However the output of :Gedit will be broken.
Originally, escaping of % is fix for :Gedit.

So, I have trouble with this problem.


daisuzu commented Jun 12, 2012

I tried following fix and it resolved this problem.
May I send a pull request?


diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
index 96cd1d6..6c09a9b 100644
--- a/plugin/fugitive.vim
+++ b/plugin/fugitive.vim
@@ -299,7 +299,11 @@ call s:add_methods('repo',['dir','configured_tree','tree','bare','translate','he

 function! s:repo_git_command(...) dict abort
   let git = g:fugitive_git_executable . ' --git-dir='.s:shellesc(self.git_dir)
-  return git.join(map(copy(a:000),'" ".s:shellesc(v:val)'),'')
+  if &shell =~# 'cmd' && index(a:000, 'log') > -1
+    return git.join(map(copy(a:000),'v:val=~"%" ? " "."\"".v:val."\"" : " ".s:shellesc(v:val)'),'')
+  else
+    return git.join(map(copy(a:000),'" ".s:shellesc(v:val)'),'')
+  endif

 function! s:repo_git_chomp(...) dict abort

tpope closed this in 5298448 Jul 11, 2012


tpope commented Jul 11, 2012

You don't need permission to open a pull request :). But making git_command responsible for special casing log is the wrong way to go. The problem is specific to :Glog, not log in general.

This problem seemed pretty daunting a month ago, but this time around the solution was readily apparent. I've pushed up a fix.


daisuzu commented Jul 12, 2012

Hi, Tim.
Thanks for fix and comment.

Now, :Glog works normally on Windows.
I verified git ver 1.7.7 and 1.7.11.

I've worried about my fix effects on other command,
and your comment is absolutely right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment