Remove hard coded length limit of 40 on hashes
SHA-256 is coming eventually, may as well rip these out now.
This commit is contained in:
parent
302ee3b41c
commit
fc6643c318
@ -363,7 +363,7 @@ function! fugitive#Head(...) abort
|
|||||||
let head = readfile(fugitive#Find('.git/HEAD', dir))[0]
|
let head = readfile(fugitive#Find('.git/HEAD', dir))[0]
|
||||||
if head =~# '^ref: '
|
if head =~# '^ref: '
|
||||||
return substitute(head, '\C^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '')
|
return substitute(head, '\C^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '')
|
||||||
elseif head =~# '^\x\{40\}$'
|
elseif head =~# '^\x\{40,\}$'
|
||||||
let len = a:0 ? a:1 : 0
|
let len = a:0 ? a:1 : 0
|
||||||
return len < 0 ? head : len ? head[0:len-1] : ''
|
return len < 0 ? head : len ? head[0:len-1] : ''
|
||||||
else
|
else
|
||||||
@ -373,7 +373,7 @@ endfunction
|
|||||||
|
|
||||||
function! fugitive#RevParse(rev, ...) abort
|
function! fugitive#RevParse(rev, ...) abort
|
||||||
let [hash, exec_error] = s:ChompError([a:0 ? a:1 : s:Dir(), 'rev-parse', '--verify', a:rev, '--'])
|
let [hash, exec_error] = s:ChompError([a:0 ? a:1 : s:Dir(), 'rev-parse', '--verify', a:rev, '--'])
|
||||||
if !exec_error && hash =~# '^\x\{40\}$'
|
if !exec_error && hash =~# '^\x\{40,\}$'
|
||||||
return hash
|
return hash
|
||||||
endif
|
endif
|
||||||
call s:throw('rev-parse '.a:rev.': '.hash)
|
call s:throw('rev-parse '.a:rev.': '.hash)
|
||||||
@ -576,7 +576,7 @@ call s:add_methods('repo',['config', 'user'])
|
|||||||
" Section: File API
|
" Section: File API
|
||||||
|
|
||||||
function! s:DirCommitFile(path) abort
|
function! s:DirCommitFile(path) abort
|
||||||
let vals = matchlist(s:Slash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
|
let vals = matchlist(s:Slash(a:path), '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40,\}\|[0-3]\)\(/.*\)\=$')
|
||||||
if empty(vals)
|
if empty(vals)
|
||||||
return ['', '', '']
|
return ['', '', '']
|
||||||
endif
|
endif
|
||||||
@ -596,7 +596,7 @@ function! s:Owner(path, ...) abort
|
|||||||
let actualdir = fugitive#Find('.git/', dir)
|
let actualdir = fugitive#Find('.git/', dir)
|
||||||
let [pdir, commit, file] = s:DirCommitFile(a:path)
|
let [pdir, commit, file] = s:DirCommitFile(a:path)
|
||||||
if s:cpath(dir, pdir)
|
if s:cpath(dir, pdir)
|
||||||
if commit =~# '^\x\{40\}$'
|
if commit =~# '^\x\{40,\}$'
|
||||||
return commit
|
return commit
|
||||||
elseif commit ==# '2'
|
elseif commit ==# '2'
|
||||||
return 'HEAD^{}'
|
return 'HEAD^{}'
|
||||||
@ -789,7 +789,7 @@ function! fugitive#Find(object, ...) abort
|
|||||||
return file
|
return file
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if commit !~# '^[0-9a-f]\{40\}$'
|
if commit !~# '^[0-9a-f]\{40,\}$'
|
||||||
let commit = s:ChompDefault('', [dir, 'rev-parse', '--verify', commit, '--'])
|
let commit = s:ChompDefault('', [dir, 'rev-parse', '--verify', commit, '--'])
|
||||||
endif
|
endif
|
||||||
if len(commit)
|
if len(commit)
|
||||||
@ -942,7 +942,7 @@ function! s:TreeInfo(dir, commit) abort
|
|||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
return [get(s:indexes[a:dir][1], a:commit[-1:-1], {}), newftime]
|
return [get(s:indexes[a:dir][1], a:commit[-1:-1], {}), newftime]
|
||||||
elseif a:commit =~# '^\x\{40\}$'
|
elseif a:commit =~# '^\x\{40,\}$'
|
||||||
if !has_key(s:trees, a:dir)
|
if !has_key(s:trees, a:dir)
|
||||||
let s:trees[a:dir] = {}
|
let s:trees[a:dir] = {}
|
||||||
endif
|
endif
|
||||||
@ -1141,7 +1141,7 @@ function! fugitive#writefile(lines, url, ...) abort
|
|||||||
call call('writefile', [a:lines, temp] + a:000)
|
call call('writefile', [a:lines, temp] + a:000)
|
||||||
let [hash, exec_error] = s:ChompError([dir, 'hash-object', '-w', temp])
|
let [hash, exec_error] = s:ChompError([dir, 'hash-object', '-w', temp])
|
||||||
let mode = len(entry[1]) ? entry[1] : '100644'
|
let mode = len(entry[1]) ? entry[1] : '100644'
|
||||||
if !exec_error && hash =~# '^\x\{40\}$'
|
if !exec_error && hash =~# '^\x\{40,\}$'
|
||||||
let exec_error = s:SystemError([dir, 'update-index', '--index-info'],
|
let exec_error = s:SystemError([dir, 'update-index', '--index-info'],
|
||||||
\ mode . ' ' . hash . ' ' . commit . "\t" . file[1:-1])[1]
|
\ mode . ' ' . hash . ' ' . commit . "\t" . file[1:-1])[1]
|
||||||
if !exec_error
|
if !exec_error
|
||||||
@ -2869,8 +2869,8 @@ function! s:RebaseEdit(cmd, dir) abort
|
|||||||
let shas = {}
|
let shas = {}
|
||||||
|
|
||||||
for i in range(len(new))
|
for i in range(len(new))
|
||||||
if new[i] =~# '^\l\+\s\+[0-9a-f]\{3,\}\>'
|
if new[i] =~# '^\l\+\s\+[0-9a-f]\{5,\}\>'
|
||||||
let sha = matchstr(new[i], '\C\v[a-f0-9]{5,40}')
|
let sha = matchstr(new[i], '\C\<[a-f0-9]\{5,\}\>')
|
||||||
if !sha_length
|
if !sha_length
|
||||||
let sha_length = len(s:TreeChomp(a:dir, 'rev-parse', '--short', sha))
|
let sha_length = len(s:TreeChomp(a:dir, 'rev-parse', '--short', sha))
|
||||||
endif
|
endif
|
||||||
@ -3027,10 +3027,10 @@ function! s:RebaseClean(file) abort
|
|||||||
for i in range(len(new))
|
for i in range(len(new))
|
||||||
let new[i] = substitute(new[i], '^\l\>', '\=get(s:rebase_abbrevs,submatch(0),submatch(0))', '')
|
let new[i] = substitute(new[i], '^\l\>', '\=get(s:rebase_abbrevs,submatch(0),submatch(0))', '')
|
||||||
|
|
||||||
let sha = matchstr(new[i], '\C\v[a-f0-9]{5,40}')
|
let sha = matchstr(new[i], '\C\<[a-f0-9]\{5,\}\>')
|
||||||
let rebase_shas = getbufvar(a:file, 'fugitive_rebase_shas')
|
let rebase_shas = getbufvar(a:file, 'fugitive_rebase_shas')
|
||||||
if len(sha) && type(rebase_shas) == type({}) && has_key(rebase_shas, sha)
|
if len(sha) && type(rebase_shas) == type({}) && has_key(rebase_shas, sha)
|
||||||
let new[i] = substitute(new[i], sha, rebase_shas[sha], '')
|
let new[i] = substitute(new[i], '\C\<' . sha . '\>', rebase_shas[sha], '')
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
if new !=# old
|
if new !=# old
|
||||||
@ -3927,7 +3927,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:BlameCommit(cmd, ...) abort
|
function! s:BlameCommit(cmd, ...) abort
|
||||||
let line = a:0 ? a:1 : getline('.')
|
let line = a:0 ? a:1 : getline('.')
|
||||||
if line =~# '^0\{4,40\} '
|
if line =~# '^0\{4,\} '
|
||||||
return 'echoerr ' . string('Not Committed Yet')
|
return 'echoerr ' . string('Not Committed Yet')
|
||||||
endif
|
endif
|
||||||
let cmd = s:Open(a:cmd, 0, '', matchstr(line, '\x\+'), [matchstr(line, '\x\+')])
|
let cmd = s:Open(a:cmd, 0, '', matchstr(line, '\x\+'), [matchstr(line, '\x\+')])
|
||||||
@ -4019,8 +4019,8 @@ function! s:BlameSyntax() abort
|
|||||||
let arg = exists('b:fugitive_blame_arguments') ? b:fugitive_blame_arguments : ''
|
let arg = exists('b:fugitive_blame_arguments') ? b:fugitive_blame_arguments : ''
|
||||||
syn match FugitiveblameBoundary "^\^"
|
syn match FugitiveblameBoundary "^\^"
|
||||||
syn match FugitiveblameBlank "^\s\+\s\@=" nextgroup=FugitiveblameAnnotation,fugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite
|
syn match FugitiveblameBlank "^\s\+\s\@=" nextgroup=FugitiveblameAnnotation,fugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite
|
||||||
syn match FugitiveblameHash "\%(^\^\=\)\@<=\<\x\{7,40\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite
|
syn match FugitiveblameHash "\%(^\^\=\)\@<=\<\x\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite
|
||||||
syn match FugitiveblameUncommitted "\%(^\^\=\)\@<=\<0\{7,40\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite
|
syn match FugitiveblameUncommitted "\%(^\^\=\)\@<=\<0\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite
|
||||||
syn region FugitiveblameAnnotation matchgroup=FugitiveblameDelimiter start="(" end="\%( \d\+\)\@<=)" contained keepend oneline
|
syn region FugitiveblameAnnotation matchgroup=FugitiveblameDelimiter start="(" end="\%( \d\+\)\@<=)" contained keepend oneline
|
||||||
syn match FugitiveblameTime "[0-9:/+-][0-9:/+ -]*[0-9:/+-]\%( \+\d\+)\)\@=" contained containedin=FugitiveblameAnnotation
|
syn match FugitiveblameTime "[0-9:/+-][0-9:/+ -]*[0-9:/+-]\%( \+\d\+)\)\@=" contained containedin=FugitiveblameAnnotation
|
||||||
exec 'syn match FugitiveblameLineNumber " *\d\+)\@=" contained containedin=FugitiveblameAnnotation'.conceal
|
exec 'syn match FugitiveblameLineNumber " *\d\+)\@=" contained containedin=FugitiveblameAnnotation'.conceal
|
||||||
@ -4135,7 +4135,7 @@ function! s:BrowseCommand(line1, line2, range, count, bang, mods, reg, arg, args
|
|||||||
endif
|
endif
|
||||||
if path =~# '^\.git/.*HEAD$' && filereadable(dir . '/' . path[5:-1])
|
if path =~# '^\.git/.*HEAD$' && filereadable(dir . '/' . path[5:-1])
|
||||||
let body = readfile(dir . '/' . path[5:-1])[0]
|
let body = readfile(dir . '/' . path[5:-1])[0]
|
||||||
if body =~# '^\x\{40\}$'
|
if body =~# '^\x\{40,\}$'
|
||||||
let commit = body
|
let commit = body
|
||||||
let type = 'commit'
|
let type = 'commit'
|
||||||
let path = ''
|
let path = ''
|
||||||
@ -4192,7 +4192,7 @@ function! s:BrowseCommand(line1, line2, range, count, bang, mods, reg, arg, args
|
|||||||
if exec_error
|
if exec_error
|
||||||
let commit = ''
|
let commit = ''
|
||||||
endif
|
endif
|
||||||
if a:count && empty(a:args) && commit =~# '^\x\{40\}$'
|
if a:count && empty(a:args) && commit =~# '^\x\{40,\}$'
|
||||||
let blame_list = tempname()
|
let blame_list = tempname()
|
||||||
call writefile([commit, ''], blame_list, 'b')
|
call writefile([commit, ''], blame_list, 'b')
|
||||||
let blame_in = tempname()
|
let blame_in = tempname()
|
||||||
@ -4354,7 +4354,7 @@ function! fugitive#MapJumps(...) abort
|
|||||||
nnoremap <buffer> <silent> O :<C-U>exe <SID>GF("tabedit")<CR>
|
nnoremap <buffer> <silent> O :<C-U>exe <SID>GF("tabedit")<CR>
|
||||||
nnoremap <buffer> <silent> p :<C-U>exe <SID>GF("pedit")<CR>
|
nnoremap <buffer> <silent> p :<C-U>exe <SID>GF("pedit")<CR>
|
||||||
endif
|
endif
|
||||||
exe "nnoremap <buffer> <silent>" nowait "- :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>NavigateUp(v:count1))<Bar> if getline(1) =~# '^tree \x\{40\}$' && empty(getline(2))<Bar>call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')<Bar>endif<CR>"
|
exe "nnoremap <buffer> <silent>" nowait "- :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>NavigateUp(v:count1))<Bar> if getline(1) =~# '^tree \x\{40,\}$' && empty(getline(2))<Bar>call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')<Bar>endif<CR>"
|
||||||
nnoremap <buffer> <silent> P :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'^'.v:count1.<SID>Relative(':'))<CR>
|
nnoremap <buffer> <silent> P :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'^'.v:count1.<SID>Relative(':'))<CR>
|
||||||
nnoremap <buffer> <silent> ~ :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'~'.v:count1.<SID>Relative(':'))<CR>
|
nnoremap <buffer> <silent> ~ :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'~'.v:count1.<SID>Relative(':'))<CR>
|
||||||
nnoremap <buffer> <silent> C :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit())<CR>
|
nnoremap <buffer> <silent> C :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit())<CR>
|
||||||
@ -4466,7 +4466,7 @@ function! s:cfile() abort
|
|||||||
let treebase = substitute(s:DirCommitFile(@%)[1], '^\d$', ':&', '') . ':' .
|
let treebase = substitute(s:DirCommitFile(@%)[1], '^\d$', ':&', '') . ':' .
|
||||||
\ s:Relative('') . (s:Relative('') =~# '^$\|/$' ? '' : '/')
|
\ s:Relative('') . (s:Relative('') =~# '^$\|/$' ? '' : '/')
|
||||||
|
|
||||||
if getline('.') =~# '^\d\{6\} \l\{3,8\} \x\{40\}\t'
|
if getline('.') =~# '^\d\{6\} \l\{3,8\} \x\{40,\}\t'
|
||||||
return [treebase . s:sub(matchstr(getline('.'),'\t\zs.*'),'/$','')]
|
return [treebase . s:sub(matchstr(getline('.'),'\t\zs.*'),'/$','')]
|
||||||
elseif showtree
|
elseif showtree
|
||||||
return [treebase . s:sub(getline('.'),'/$','')]
|
return [treebase . s:sub(getline('.'),'/$','')]
|
||||||
@ -4476,8 +4476,8 @@ function! s:cfile() abort
|
|||||||
let dcmds = []
|
let dcmds = []
|
||||||
|
|
||||||
" Index
|
" Index
|
||||||
if getline('.') =~# '^\d\{6\} \x\{40\} \d\t'
|
if getline('.') =~# '^\d\{6\} \x\{40,\} \d\t'
|
||||||
let ref = matchstr(getline('.'),'\x\{40\}')
|
let ref = matchstr(getline('.'),'\x\{40,\}')
|
||||||
let file = ':'.s:sub(matchstr(getline('.'),'\d\t.*'),'\t',':')
|
let file = ':'.s:sub(matchstr(getline('.'),'\d\t.*'),'\t',':')
|
||||||
return [file]
|
return [file]
|
||||||
endif
|
endif
|
||||||
@ -4485,12 +4485,12 @@ function! s:cfile() abort
|
|||||||
if getline('.') =~# '^ref: '
|
if getline('.') =~# '^ref: '
|
||||||
let ref = strpart(getline('.'),5)
|
let ref = strpart(getline('.'),5)
|
||||||
|
|
||||||
elseif getline('.') =~# '^commit \x\{40\}\>'
|
elseif getline('.') =~# '^commit \x\{40,\}\>'
|
||||||
let ref = matchstr(getline('.'),'\x\{40\}')
|
let ref = matchstr(getline('.'),'\x\{40,\}')
|
||||||
return [ref]
|
return [ref]
|
||||||
|
|
||||||
elseif getline('.') =~# '^parent \x\{40\}\>'
|
elseif getline('.') =~# '^parent \x\{40,\}\>'
|
||||||
let ref = matchstr(getline('.'),'\x\{40\}')
|
let ref = matchstr(getline('.'),'\x\{40,\}')
|
||||||
let line = line('.')
|
let line = line('.')
|
||||||
let parent = 0
|
let parent = 0
|
||||||
while getline(line) =~# '^parent '
|
while getline(line) =~# '^parent '
|
||||||
@ -4499,22 +4499,22 @@ function! s:cfile() abort
|
|||||||
endwhile
|
endwhile
|
||||||
return [ref]
|
return [ref]
|
||||||
|
|
||||||
elseif getline('.') =~# '^tree \x\{40\}$'
|
elseif getline('.') =~# '^tree \x\{40,\}$'
|
||||||
let ref = matchstr(getline('.'),'\x\{40\}')
|
let ref = matchstr(getline('.'),'\x\{40,\}')
|
||||||
if len(myhash) && fugitive#RevParse(myhash.':') ==# ref
|
if len(myhash) && fugitive#RevParse(myhash.':') ==# ref
|
||||||
let ref = myhash.':'
|
let ref = myhash.':'
|
||||||
endif
|
endif
|
||||||
return [ref]
|
return [ref]
|
||||||
|
|
||||||
elseif getline('.') =~# '^object \x\{40\}$' && getline(line('.')+1) =~ '^type \%(commit\|tree\|blob\)$'
|
elseif getline('.') =~# '^object \x\{40,\}$' && getline(line('.')+1) =~ '^type \%(commit\|tree\|blob\)$'
|
||||||
let ref = matchstr(getline('.'),'\x\{40\}')
|
let ref = matchstr(getline('.'),'\x\{40,\}')
|
||||||
let type = matchstr(getline(line('.')+1),'type \zs.*')
|
let type = matchstr(getline(line('.')+1),'type \zs.*')
|
||||||
|
|
||||||
elseif getline('.') =~# '^\l\{3,8\} '.myhash.'$'
|
elseif getline('.') =~# '^\l\{3,8\} '.myhash.'$'
|
||||||
let ref = s:DirRev(@%)[1]
|
let ref = s:DirRev(@%)[1]
|
||||||
|
|
||||||
elseif getline('.') =~# '^\l\{3,8\} \x\{40\}\>'
|
elseif getline('.') =~# '^\l\{3,8\} \x\{40,\}\>'
|
||||||
let ref = matchstr(getline('.'),'\x\{40\}')
|
let ref = matchstr(getline('.'),'\x\{40,\}')
|
||||||
echoerr "warning: unknown context ".matchstr(getline('.'),'^\l*')
|
echoerr "warning: unknown context ".matchstr(getline('.'),'^\l*')
|
||||||
|
|
||||||
elseif getline('.') =~# '^[+-]\{3\} [abciow12]\=/'
|
elseif getline('.') =~# '^[+-]\{3\} [abciow12]\=/'
|
||||||
@ -4558,10 +4558,10 @@ function! s:cfile() abort
|
|||||||
let ref = matchstr(line,'\Cdiff --git \%([abciow12]/.*\|/dev/null\) \zs\%([abciow12]/.*\|/dev/null\)')
|
let ref = matchstr(line,'\Cdiff --git \%([abciow12]/.*\|/dev/null\) \zs\%([abciow12]/.*\|/dev/null\)')
|
||||||
let dcmd = 'Gdiff!'
|
let dcmd = 'Gdiff!'
|
||||||
|
|
||||||
elseif line('$') == 1 && getline('.') =~ '^\x\{40\}$'
|
elseif line('$') == 1 && getline('.') =~ '^\x\{40,\}$'
|
||||||
let ref = getline('.')
|
let ref = getline('.')
|
||||||
|
|
||||||
elseif expand('<cword>') =~# '^\x\{7,40\}\>'
|
elseif expand('<cword>') =~# '^\x\{7,\}\>'
|
||||||
return [expand('<cword>')]
|
return [expand('<cword>')]
|
||||||
|
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user