Jump directly to commit rather than ref file in more cases

This commit is contained in:
Tim Pope 2018-06-15 15:31:27 -04:00
parent f7bcf51c56
commit bb54881388
2 changed files with 7 additions and 17 deletions

View File

@ -275,23 +275,13 @@ function! s:repo_translate(spec) dict abort
return 'fugitive://'.self.dir().'//'.ref
elseif a:spec =~# '^:'
return 'fugitive://'.self.dir().'//0/'.a:spec[1:-1]
elseif a:spec ==# '@'
return self.dir('HEAD')
elseif a:spec =~# 'HEAD\|^refs/' && a:spec !~ ':' && filereadable(refs . '../' . a:spec)
return simplify(refs . '../' . a:spec)
elseif filereadable(refs.a:spec)
return refs.a:spec
elseif filereadable(refs.'tags/'.a:spec)
return refs.'tags/'.a:spec
elseif filereadable(refs.'heads/'.a:spec)
return refs.'heads/'.a:spec
elseif filereadable(refs.'remotes/'.a:spec)
return refs.'remotes/'.a:spec
elseif filereadable(refs.'remotes/'.a:spec.'/HEAD')
return refs.'remotes/'.a:spec.'/HEAD'
else
try
let ref = self.rev_parse(matchstr(a:spec,'[^:]*'))
let ref = self.rev_parse(s:sub(matchstr(a:spec,'[^:]*'), '^\@%($|[^~])@=', 'HEAD'))
let path = s:sub(matchstr(a:spec,':.*'),'^:','/')
return 'fugitive://'.self.dir().'//'.ref.path
catch /^fugitive:/

View File

@ -330,13 +330,13 @@ and the work tree file for everything else. Example revisions follow.
Revision Meaning ~
HEAD .git/HEAD
master .git/refs/heads/master
HEAD^{} The commit referenced by HEAD
HEAD^ The parent of the commit referenced by HEAD
HEAD: The tree referenced by HEAD
/HEAD The file named HEAD in the work tree
refs/heads/x .git/refs/heads/x
@ The commit referenced by @ aka HEAD
master^ The parent of the commit referenced by master
master: The tree referenced by master
/master The file named master in the work tree
Makefile The file named Makefile in the work tree
HEAD^:Makefile The file named Makefile in the parent of HEAD
@^:Makefile The file named Makefile in the parent of HEAD
:Makefile The file named Makefile in the index (writable)
- The current file in HEAD
^ The current file in the previous commit