Skip to content

Commit

Permalink
Merge pull request #42 from rbialon/fix/use-git-env-variables
Browse files Browse the repository at this point in the history
Use git environment variables if set
  • Loading branch information
rhysd authored Feb 24, 2018
2 parents febc451 + 8c47bb2 commit 7f7bc74
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions autoload/committia/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ function! s:extract_first_line(str) abort
endfunction

function! s:search_git_dir_and_work_tree() abort
" Use environment variables if set
if !empty($GIT_DIR) && !empty($GIT_WORK_TREE)
if !isdirectory($GIT_WORK_TREE)
throw 'Directory specified with $GIT_WORK_TREE does not exist: ' . $GIT_WORK_TREE
endif
return [$GIT_DIR, $GIT_WORK_TREE]
endif

" '/.git' is unnecessary under submodule directory.
let matched = matchlist(expand('%:p'), '[\\/]\.git[\\/]\%(\(modules\|worktrees\)[\\/].\+[\\/]\)\?\%(COMMIT_EDITMSG\|MERGE_MSG\)$')
if len(matched) > 1
Expand Down

0 comments on commit 7f7bc74

Please sign in to comment.