Skip to content

Commit

Permalink
Resolve worktree relative to git dir
Browse files Browse the repository at this point in the history
  • Loading branch information
rbong committed Sep 23, 2024
1 parent d58ee18 commit be33ab0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions autoload/flog/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ function! flog#git#GetWorkdirFrom(git_dir) abort
let l:cmd = ['git', '--git-dir', flog#shell#Escape(a:git_dir)]
let l:parent = fnamemodify(a:git_dir, ':h')

" Check for core.worktree setting
let l:worktree = flog#shell#Systemlist(l:cmd + ['config', '--get', 'core.worktree'])
if empty(v:shell_error) && !empty(l:worktree)
let l:worktree = flog#path#ResolveFrom(l:parent, l:worktree[0])
if isdirectory(l:worktree)
return l:worktree
endif
endif

" Check for file-based git dir
if filereadable(a:git_dir)
let l:content = readfile(a:git_dir)
Expand All @@ -35,6 +26,15 @@ function! flog#git#GetWorkdirFrom(git_dir) abort
return ''
endif

" Check for core.worktree setting
let l:worktree = flog#shell#Systemlist(l:cmd + ['config', '--get', 'core.worktree'])
if empty(v:shell_error) && !empty(l:worktree)
let l:worktree = flog#path#ResolveFrom(a:git_dir, l:worktree[0])
if isdirectory(l:worktree)
return l:worktree
endif
endif

" Check for git dir file
let l:gitdir_file = a:git_dir .. '/gitdir'
if filereadable(l:gitdir_file)
Expand Down

0 comments on commit be33ab0

Please sign in to comment.