Skip to content

Commit

Permalink
Look for $GIT_DIR and $GIT_WORK_TREE
Browse files Browse the repository at this point in the history
There are rare situations where a user has manually specified what they
wish to use as their work-tree directory, and even rarer situations
where the user wishes the Git directory to be customized. In the case
the user has set these using environment variables, vim-fugitive takes
advantage of these settings in order to set up.

Note that git-config(1) allows setting the work-tree and Git dir in
a number of ways (see the core.worktree) setting. This change only
respects the environment variable method, not the config file method.
  • Loading branch information
Emily Strickland authored and tpope committed Mar 5, 2014
1 parent 190fe2a commit 0cb3054
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugin/fugitive.vim
Expand Up @@ -139,6 +139,9 @@ function! fugitive#extract_git_dir(path) abort
if index(split($GIT_CEILING_DIRECTORIES, ':'), root) >= 0
break
endif
if root ==# $GIT_WORK_TREE && fugitive#is_git_dir($GIT_DIR)
return $GIT_DIR
endif
let dir = s:sub(root, '[\/]$', '') . '/.git'
let type = getftype(dir)
if type ==# 'dir' && fugitive#is_git_dir(dir)
Expand Down

0 comments on commit 0cb3054

Please sign in to comment.