From 06a9997da744f95d9702ced048c86f75467726e2 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Fri, 6 Oct 2023 17:38:01 -0700 Subject: [PATCH] fix git diff and improve git diff detection --- chk_tree | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/chk_tree b/chk_tree index 61a3e23..2e2b806 100755 --- a/chk_tree +++ b/chk_tree @@ -143,21 +143,21 @@ if [[ -d .git ]]; then echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 fi - # verify that there are no uncommitted changes under git + # verify that there are no staged uncommitted changes under git # GIT_STATUS=$(git status --untracked-files=no --porcelain 2>&1) - if [[ -n $GIT_STATUS ]] || ! diff --quiet --exit-code; then - echo "$0: ERROR: there are unstaged changes" 1>&2 - git status --untracked-files=no --porcelain --short + if [[ -n $GIT_STATUS ]] || ! git diff --cached --quiet --exit-code; then + echo "$0: ERROR: there are staged uncommitted changes" 1>&2 + git status --short EXIT_CODE=14 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 fi - # verify that there are no staged uncommitted changes under git + # verify that there are no uncommitted changes under git # - if ! git diff --cached --quiet --exit-code; then - echo "$0: ERROR: there are staged uncommitted changes" 1>&2 - git status --short + if ! git diff --quiet --exit-code; then + echo "$0: ERROR: there are unstaged changes" 1>&2 + git status --untracked-files=no --porcelain --short EXIT_CODE=15 echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2 fi