Reverse order of if conditional

Checking for readability is a cheaper operation that `git diff-index`.
This commit is contained in:
Carlo Cabrera 2024-08-28 18:58:27 +08:00
parent 58ea96583f
commit a597a1eecb
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -458,8 +458,8 @@ if [[ -n "${GIT_REVISION}" ]]
then
GIT_DESCRIBE_CACHE_FILE="${GIT_DESCRIBE_CACHE}/${GIT_REVISION}"
# Pass `--` to guard against `git` being confused by a file named `HEAD`.
if "${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" diff-index --quiet --exit-code HEAD -- 2>/dev/null &&
[[ -r "${GIT_DESCRIBE_CACHE_FILE}" ]]
if [[ -r "${GIT_DESCRIBE_CACHE_FILE}" ]] &&
"${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" diff-index --quiet HEAD -- 2>/dev/null
then
read -r GIT_DESCRIBE_CACHE_HOMEBREW_VERSION <"${GIT_DESCRIBE_CACHE_FILE}"
if [[ -n "${GIT_DESCRIBE_CACHE_HOMEBREW_VERSION}" && "${GIT_DESCRIBE_CACHE_HOMEBREW_VERSION}" != *"-dirty" ]]