Skip to content

Commit

Permalink
Fix _forgit_diff on macOS (#375)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sandr01d committed Mar 27, 2024
1 parent 0a8a70b commit d582f2a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/git-forgit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d582f2a

Please sign in to comment.