From d2d2da11c58c09d314b23029bdd4a4ab747d76e2 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Tue, 31 Jul 2018 14:28:36 +0100 Subject: [PATCH] Add g:gitgutter_git_args for args to git when running git-diff. See #541, #546. --- README.mkd | 9 +++++++++ autoload/gitgutter/diff.vim | 2 +- doc/gitgutter.txt | 10 ++++++++++ plugin/gitgutter.vim | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index baf712d..d87367a 100644 --- a/README.mkd +++ b/README.mkd @@ -212,6 +212,7 @@ You can customise: * The signs' colours and symbols * Line highlights * The base of the diff +* Extra arguments for `git` when running `git diff` * Extra arguments for `git diff` * Key mappings * Whether or not vim-gitgutter is on initially (defaults to on) @@ -297,6 +298,14 @@ let g:gitgutter_diff_base = '' ``` +#### Extra arguments for `git` when running `git diff` + +If you want to pass extra arguments to `git` when running `git diff`, do so like this: + +```viml +let g:gitgutter_git_args = '--git-dir-""' +``` + #### Extra arguments for `git diff` If you want to pass extra arguments to `git diff`, for example to ignore whitespace, do so like this: diff --git a/autoload/gitgutter/diff.vim b/autoload/gitgutter/diff.vim index 9441f7a..356a3b0 100644 --- a/autoload/gitgutter/diff.vim +++ b/autoload/gitgutter/diff.vim @@ -100,7 +100,7 @@ function! gitgutter#diff#run_diff(bufnr, preserve_full_diff) abort call s:write_buffer(a:bufnr, buff_file) " Call git-diff with the temporary files. - let cmd .= g:gitgutter_git_executable.' --no-pager' + let cmd .= g:gitgutter_git_executable.' --no-pager '.g:gitgutter_git_args if s:c_flag let cmd .= ' -c "diff.autorefreshindex=0"' let cmd .= ' -c "diff.noprefix=false"' diff --git a/doc/gitgutter.txt b/doc/gitgutter.txt index e9c8f01..d0732c3 100644 --- a/doc/gitgutter.txt +++ b/doc/gitgutter.txt @@ -232,6 +232,7 @@ Most important option:~ Git:~ |g:gitgutter_git_executable| + |g:gitgutter_git_args| |g:gitgutter_diff_args| |g:gitgutter_diff_base| @@ -270,6 +271,15 @@ Default: 'git' This option determines what git binary to use. Set this if git is not on your path. + *g:gitgutter_git_args* +Default: empty + +Use this option to pass any extra arguments to git when running git-diff. +For example: +> + let g:gitgutter_git_args = '--git-dir=""' +< + *g:gitgutter_diff_args* Default: empty diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index fd9c131..fa3d6a5 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -45,6 +45,7 @@ else endif call s:set('g:gitgutter_sign_modified_removed', '~_') +call s:set('g:gitgutter_git_args', '') call s:set('g:gitgutter_diff_args', '') call s:set('g:gitgutter_diff_base', '') call s:set('g:gitgutter_map_keys', 1)