@@ -320,6 +320,8 @@ function! s:repo_translate(spec) dict abort
320
320
return ' fugitive://' .self .dir ().' //' .ref
321
321
elseif a: spec = ~# ' ^:'
322
322
return ' fugitive://' .self .dir ().' //0/' .a: spec [1 :-1 ]
323
+ elseif a: spec == # ' @'
324
+ return self .dir (' HEAD' )
323
325
elseif a: spec = ~# ' HEAD\|^refs/' && a: spec !~ ' :' && filereadable (self .dir (a: spec ))
324
326
return self .dir (a: spec )
325
327
elseif filereadable (self .dir (' refs/' .a: spec ))
@@ -1258,7 +1260,7 @@ function! s:Grep(cmd,bang,arg) abort
1258
1260
try
1259
1261
execute cd .' `=s:repo().tree()`'
1260
1262
let &grepprg = s: repo ().git_command (' --no-pager' , ' grep' , ' -n' , ' --no-color' )
1261
- let &grepformat = ' %f:%l:%m,%f'
1263
+ let &grepformat = ' %f:%l:%m,%m %f match%ts,% f'
1262
1264
exe a: cmd .' ! ' .escape (matchstr (a: arg ,' \v\C.{-}%($|['' " ]\@=\|)@=' ),' |' )
1263
1265
let list = a: cmd = ~# ' ^l' ? getloclist (0 ) : getqflist ()
1264
1266
for entry in list
@@ -1406,6 +1408,7 @@ function! s:Edit(cmd,bang,...) abort
1406
1408
catch /^fugitive:/
1407
1409
return ' echoerr v:errmsg'
1408
1410
endtry
1411
+ let file = s: sub (file , ' /$' , ' ' )
1409
1412
if a: cmd == # ' read'
1410
1413
return ' silent %delete_|read ' .s: fnameescape (file ).' |silent 1delete_|diffupdate|' .line (' .' )
1411
1414
else
@@ -2175,7 +2178,7 @@ call s:command("-bar -bang -range -nargs=* -complete=customlist,s:EditComplete G
2175
2178
2176
2179
function ! s: Browse (bang ,line1,count ,... ) abort
2177
2180
try
2178
- let rev = a: 0 ? substitute (join (a: 000 , ' ' ),' @[[:alnum:]_-]* \%(://.\{-\}\)\=$' ,' ' ,' ' ) : ' '
2181
+ let rev = a: 0 ? substitute (join (a: 000 , ' ' ),' @[[:alnum:]_-]\w\+ \%(://.\{-\}\)\=$' ,' ' ,' ' ) : ' '
2179
2182
if rev == # ' '
2180
2183
let expanded = s: buffer ().rev ()
2181
2184
elseif rev == # ' :'
@@ -2218,7 +2221,7 @@ function! s:Browse(bang,line1,count,...) abort
2218
2221
endif
2219
2222
endif
2220
2223
2221
- if a: 0 && join (a: 000 , ' ' ) = ~# ' @[[:alnum:]_-]* \%(://.\{-\}\)\=$'
2224
+ if a: 0 && join (a: 000 , ' ' ) = ~# ' @[[:alnum:]_-]\+ \%(://.\{-\}\)\=$'
2222
2225
let remote = matchstr (join (a: 000 , ' ' ),' @\zs[[:alnum:]_-]\+\%(://.\{-\}\)\=$' )
2223
2226
elseif path = ~# ' ^\.git/refs/remotes/.'
2224
2227
let remote = matchstr (path ,' ^\.git/refs/remotes/\zs[^/]\+' )
@@ -2319,27 +2322,21 @@ function! s:github_url(opts, ...) abort
2319
2322
return root . ' /commits/' . branch
2320
2323
endif
2321
2324
elseif path = ~# ' ^\.git/refs/tags/'
2322
- return root . ' /releases/tag/' . matchstr ( path , ' [^/]\+$ ' )
2323
- elseif path = ~# ' ^\.git/refs/.'
2324
- return root . ' /commits/' . matchstr (path ,' [^/]\+$ ' )
2325
+ return root . ' /releases/tag/' . path [ 15 : -1 ]
2326
+ elseif path = ~# ' ^\.git/refs/remotes/[^/]\+/ .'
2327
+ return root . ' /commits/' . matchstr (path ,' remotes/ [^/]\+/\zs.* ' )
2325
2328
elseif path = ~# ' .git/\%(config$\|hooks\>\)'
2326
2329
return root . ' /admin'
2327
2330
elseif path = ~# ' ^\.git\>'
2328
2331
return root
2329
2332
endif
2330
- if a: opts .revision = ~# ' ^[[:alnum:]._-]\+:'
2331
- let commit = matchstr (a: opts .revision,' ^[^:]*' )
2332
- elseif a: opts .commit = ~# ' ^\d\=$'
2333
- let local = matchstr (a: opts .repo.head_ref (),' \<refs/heads/\zs.*' )
2334
- let commit = a: opts .repo.git_chomp (' config' ,' branch.' .local.' .merge' )[11 :-1 ]
2335
- if commit == # ' '
2336
- let commit = local
2337
- endif
2333
+ if a: opts .commit = ~# ' ^\d\=$'
2334
+ let commit = a: opts .repo.rev_parse (' HEAD' )
2338
2335
else
2339
2336
let commit = a: opts .commit
2340
2337
endif
2341
- if a: opts. type == ' tree'
2342
- let url = s: sub (root . ' /tree/' . commit . ' /' . path ,' /$' ,' ' )
2338
+ if get ( a: opts, ' type' , ' ' ) == # ' tree' || a: opts . path = ~# ' /$ '
2339
+ let url = substitute (root . ' /tree/' . commit . ' /' . path , ' /$' , ' ' , ' g ' )
2343
2340
elseif a: opts .type == ' blob'
2344
2341
let url = root . ' /blob/' . commit . ' /' . path
2345
2342
if get (a: opts , ' line2' ) && a: opts .line1 == a: opts .line2
@@ -2372,10 +2369,8 @@ function! s:instaweb_url(opts) abort
2372
2369
endif
2373
2370
let url .= ' ;h=' . a: opts .repo.rev_parse (a: opts .commit . (a: opts .path == ' ' ? ' ' : ' :' . a: opts .path ))
2374
2371
else
2375
- if a: opts .type == # ' blob'
2376
- let tmp = tempname ()
2377
- silent execute ' write !' .a: opts .repo.git_command (' hash-object' ,' -w' ,' --stdin' ).' > ' .tmp
2378
- let url .= ' ;h=' . readfile (tmp)[0 ]
2372
+ if a: opts .type == # ' blob' && empty (a: opts .commit)
2373
+ let url .= ' ;h=' .a: opts .repo.git_chomp (' hash-object' , ' -w' , a: opts .path )
2379
2374
else
2380
2375
try
2381
2376
let url .= ' ;h=' . a: opts .repo.rev_parse ((a: opts .commit == ' ' ? ' HEAD' : ' :' . a: opts .commit) . ' :' . a: opts .path )
@@ -2855,7 +2850,7 @@ function! s:cfile() abort
2855
2850
elseif getline (' .' ) = ~# ' ^[+-]' && search (' ^@@ -\d\+,\d\+ +\d\+,' ,' bnW' )
2856
2851
let type = getline (' .' )[0 ]
2857
2852
let lnum = line (' .' ) - 1
2858
- let offset = -1
2853
+ let offset = 0
2859
2854
while getline (lnum) !~# ' ^@@ -\d\+,\d\+ +\d\+,'
2860
2855
if getline (lnum) = ~# ' ^[ ' .type .' ]'
2861
2856
let offset += 1
0 commit comments