diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 9558c32..162b893 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -915,8 +915,8 @@ function! fugitive#Find(object, ...) abort let f = 'fugitive://' . dir . '//0/' . rev[1:-1] else if !exists('f') - let commit = substitute(matchstr(rev, '^[^:]\+\|^:.*'), '^@\%($\|[~^]\|@{\)\@=', 'HEAD', '') - let file = substitute(matchstr(rev, '^[^:]\+\zs:.*'), '^:', '/', '') + let commit = substitute(matchstr(rev, '^[^:.-][^:]*\|^:.*'), '^@\%($\|[~^]\|@{\)\@=', 'HEAD', '') + let file = substitute(matchstr(rev, '^[^:.-][^:]*\zs:.*'), '^:', '/', '') if file =~# '^/\.\.\=\%(/\|$\)\|^//\|^/\a\+:' let file = file =~# '^/\.' ? simplify(getcwd() . file) : file[1:-1] if s:cpath(base . '/', (file . '/')[0 : len(base)]) @@ -929,6 +929,11 @@ function! fugitive#Find(object, ...) abort return file endif endif + let commits = split(commit, '\.\.\.-\@!', 1) + if len(commits) == 2 + call map(commits, 'empty(v:val) || v:val ==# "@" ? "HEAD" : v:val') + let commit = matchstr(s:ChompDefault('', [dir, 'merge-base'] + commits + ['--']), '\<[0-9a-f]\{40,\}\>') + endif if commit !~# '^[0-9a-f]\{40,\}$' let commit = matchstr(s:ChompDefault('', [dir, 'rev-parse', '--verify', commit, '--']), '\<[0-9a-f]\{40,\}\>') endif @@ -4500,9 +4505,6 @@ function! s:Diff(autodir, keepfocus, mods, ...) abort return 'echoerr ' . string(v:exception) endtry endif - if file !~# ':' && file !~# '^/' && s:TreeChomp('cat-file','-t',file) =~# '^\%(tag\|commit\)$' - let file = file.s:Relative(':') - endif elseif exists('parents') && len(parents) let file = parents[-1] elseif len(commit) @@ -4514,6 +4516,9 @@ function! s:Diff(autodir, keepfocus, mods, ...) abort let file = s:Relative(':0:') endif let spec = s:Generate(file) + if spec =~# '^fugitive:' && empty(s:DirCommitFile(spec)[2]) + let spec = FugitiveVimPath(spec . s:Relative('/')) + endif let restore = s:diff_restore() let w:fugitive_diff_restore = restore if s:CompareAge(commit, s:DirCommitFile(spec)[1]) < 0 diff --git a/doc/fugitive.txt b/doc/fugitive.txt index 1f931ab..d4750dd 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -578,6 +578,7 @@ Object Meaning ~ @ The commit referenced by @ aka HEAD master The commit referenced by master master^ The parent of the commit referenced by master +master...other The merge base of master and other master: The tree referenced by master ./master The file named master in the working directory :(top)master The file named master in the the work tree