From f8bf95b9ff838ede04ab02487524849fb03a2576 Mon Sep 17 00:00:00 2001 From: Daniel Harding Date: Fri, 9 May 2014 13:06:44 -0500 Subject: [PATCH] Fix Gblame problems on Windows On Windows, if Vim is invoked with a working directory starting with a lowercase drive letter (e.g. c:\ instead of C:\), some mappings in the blame buffer do not work correctly. For example, hitting Enter on a line throws an exception rather than showing the associated commit. The reason for this is that the b:git_dir variable is not being set on the blame buffer. The reason in turn for this is that the path to the blame buffer is being stored in s:temp_files with an uppercase drive letter, but in the fugitive_temp augroup, ':p' is being expanded with a lowercase drive letter, so the lookup in s:temp_files fails. Fix this by converting paths to lowercase before using them as keys for the s:tempfile dictionary. Because of the way Vim generates temporary file names, this is safe even on platforms with case-sensitive file systems. --- plugin/fugitive.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 2043dfe..6b64bca 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1164,7 +1164,7 @@ function! s:Edit(cmd,bang,...) abort return 'redraw|echo '.string(':!'.git.' '.args) else let temp = resolve(tempname()) - let s:temp_files[temp] = { 'dir': buffer.repo().dir(), 'args': arglist } + let s:temp_files[tolower(temp)] = { 'dir': buffer.repo().dir(), 'args': arglist } silent execute a:cmd.' '.temp if a:cmd =~# 'pedit' wincmd P @@ -1689,7 +1689,7 @@ function! s:Blame(bang,line1,line2,count,args) abort setlocal scrollbind nowrap nofoldenable let top = line('w0') + &scrolloff let current = line('.') - let s:temp_files[temp] = { 'dir': s:repo().dir(), 'args': cmd } + let s:temp_files[tolower(temp)] = { 'dir': s:repo().dir(), 'args': cmd } exe 'keepalt leftabove vsplit '.temp let b:fugitive_blamed_bufnr = bufnr let w:fugitive_leave = restore @@ -2333,10 +2333,10 @@ endif augroup fugitive_temp autocmd! autocmd BufNewFile,BufReadPost * - \ if has_key(s:temp_files,expand(':p')) | - \ let b:git_dir = s:temp_files[expand(':p')].dir | + \ if has_key(s:temp_files,tolower(expand(':p'))) | + \ let b:git_dir = s:temp_files[tolower(expand(':p'))].dir | \ let b:git_type = 'temp' | - \ let b:git_args = s:temp_files[expand(':p')].args | + \ let b:git_args = s:temp_files[tolower(expand(':p'))].args | \ call fugitive#detect(expand(':p')) | \ setlocal bufhidden=delete | \ nnoremap q :bdelete|