From bb548813881924618b2e9d1b4f8c9917bd886408 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 15 Jun 2018 15:31:27 -0400 Subject: [PATCH] Jump directly to commit rather than ref file in more cases --- autoload/fugitive.vim | 12 +----------- doc/fugitive.txt | 12 ++++++------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index f13fe3c..6eb841d 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -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:/ diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 1c02ff5..79270e6 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -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