Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use git environment variables if set #42

Merged
merged 2 commits into from
Feb 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions autoload/committia/git.vim
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,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