diff --git a/vendor/clink.lua b/vendor/clink.lua index 5e47246..83f9387 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -280,6 +280,24 @@ local function get_svn_status() return true end +--- +-- Get the status of working dir +-- @return {bool} +--- +local function get_git_status_setting() + gitStatusSetting = io.popen("git config cmder.status") + + for line in gitStatusSetting:lines() do + if string.match(line, 'false') then + gitStatusSetting:close() + return false + end + end + gitStatusSetting:close() + + return true +end + local function git_prompt_filter() -- Colors for git status @@ -290,27 +308,30 @@ local function git_prompt_filter() } local git_dir = get_git_dir() - if git_dir then - -- if we're inside of git repo then try to detect current branch - local branch = get_git_branch(git_dir) - local color - if branch then - -- Has branch => therefore it is a git folder, now figure out status - local gitStatus = get_git_status() - local gitConflict = get_git_conflict() - color = colors.dirty - if gitStatus then - color = colors.clean - end + if get_git_status_setting() then + if git_dir then + -- if we're inside of git repo then try to detect current branch + local branch = get_git_branch(git_dir) + local color + if branch then + -- Has branch => therefore it is a git folder, now figure out status + local gitStatus = get_git_status() + local gitConflict = get_git_conflict() - if gitConflict then - color = colors.conflict - end + color = colors.dirty + if gitStatus then + color = colors.clean + end - clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") - return false - end + if gitConflict then + color = colors.conflict + end + + clink.prompt.value = string.gsub(clink.prompt.value, "{git}", color.."("..verbatim(branch)..")") + return false + end + end end -- No git present or not in git file