From de5406cdda3e197ee89935787a4b955c75f126d2 Mon Sep 17 00:00:00 2001 From: Wenxuan Zhang Date: Mon, 9 Mar 2026 17:53:35 +0800 Subject: [PATCH] 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. --- bin/git-forgit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-forgit b/bin/git-forgit index 856d8ea..7f4e4d0 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -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