From d582f2aa0b5bf7948d78aca05c55a974e68f4884 Mon Sep 17 00:00:00 2001 From: sandr01d <88739791+sandr01d@users.noreply.github.com> Date: Wed, 27 Mar 2024 20:36:07 +0100 Subject: [PATCH] Fix _forgit_diff on macOS (#375) In bash 3.2 uninitialized arrays contain one entry: an empty string, whereas in modern versions of bash they do not contain any entry. Make sure the $commits and $files arrays are explicitly initialized as empty arrays to allow git to fall back to diffing local changes instead of trying to diff against a revision with a name of an empty string. --- bin/git-forgit | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/git-forgit b/bin/git-forgit index 2db6d77e..058566c4 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -242,6 +242,8 @@ _forgit_diff_enter() { _forgit_diff() { _forgit_inside_work_tree || return 1 local files opts commits escaped_commits + commits=() + files=() [[ $# -ne 0 ]] && { if git rev-parse "$1" -- &>/dev/null ; then if [[ $# -gt 1 ]] && git rev-parse "$2" -- &>/dev/null; then