From 830b6857965e8f98e4d491ee31f750f67905625e Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Wed, 3 Aug 2022 08:57:50 -0600 Subject: [PATCH] feat: do not override user-specified cwd for git_files Use the `cwd` specified by the user if it exists; otherwise, fallback to the git repo root. --- lua/fzf-lua/providers/git.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/fzf-lua/providers/git.lua b/lua/fzf-lua/providers/git.lua index 32b6ed8..13ab610 100644 --- a/lua/fzf-lua/providers/git.lua +++ b/lua/fzf-lua/providers/git.lua @@ -9,7 +9,13 @@ local make_entry = require "fzf-lua.make_entry" local M = {} local function set_git_cwd_args(opts) - opts.cwd = path.git_root(opts) + -- verify cwd is a git repo, override user supplied + -- cwd if cwd isn't a git repo, error was already + -- printed to `:messages` by 'path.git_root' + local git_root = path.git_root(opts) + if not opts.cwd or not git_root then + opts.cwd = git_root + end if opts.git_dir or opts.git_worktree then opts.cmd = path.git_cwd(opts.cmd, opts) end