From 6f212fd2b24a415a4afd71845961afafeb55022b Mon Sep 17 00:00:00 2001 From: sandr01d <88739791+sandr01d@users.noreply.github.com> Date: Fri, 26 Apr 2024 23:03:42 +0200 Subject: [PATCH] Fix: gsp does not work outside the root directory (#386) --- bin/git-forgit | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/git-forgit b/bin/git-forgit index d1e2feb..5314268 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -455,18 +455,19 @@ _forgit_stash_push() { *) _forgit_git_stash_push "${args[@]}"; return $? esac done - local opts files + local opts files rootdir opts=" $FORGIT_FZF_DEFAULT_OPTS -m --preview=\"$FORGIT stash_push_preview {}\" $FORGIT_STASH_PUSH_FZF_OPTS " + rootdir=$(git rev-parse --show-toplevel) # Show both modified and untracked files files=() while IFS='' read -r file; do files+=("$file") - done < <(git ls-files --exclude-standard --modified --others | + done < <(git ls-files "$rootdir" --exclude-standard --modified --others | FZF_DEFAULT_OPTS="$opts" fzf --exit-0) [[ "${#files[@]}" -eq 0 ]] && echo "Nothing to stash" && return 1 _forgit_git_stash_push ${msg:+-m "$msg"} -u "${files[@]}"