fix: use array length instead of string length in reset_head

`${#files}` checks the string length of the first element, not the
array length. Use `${#files[@]}` to correctly detect an empty array.
This commit is contained in:
Wenxuan Zhang 2026-03-09 17:53:35 +08:00 committed by Wenxuan
parent 3b9ebce8bc
commit de5406cdda

View file

@ -543,7 +543,7 @@ _forgit_reset_head() {
while IFS='' read -r file; do
files+=("$file")
done < <(git diff -z --staged --name-only | tr '\0' '\n' | FZF_DEFAULT_OPTS="$opts" fzf)
if [[ ${#files} -eq 0 ]]; then
if [[ ${#files[@]} -eq 0 ]]; then
echo 'Nothing to unstage.'
return 1
fi