Skip to content

Commit bb9287b

Browse files
committed
Improve name of function that counts dirty files, and do all the needed work in the function
1 parent 49b346a commit bb9287b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

transcrypt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,12 +1596,12 @@ elif [[ $cipher ]]; then
15961596
validate_cipher
15971597
fi
15981598

1599-
list_dirty_files() {
1600-
{ git diff-index --name-status HEAD -- || git diff-index --stat HEAD -- || git diff-index HEAD -- || true; } 2>/dev/null
1599+
count_dirty_files() {
1600+
{ git diff-index --name-status HEAD -- || git diff-index --stat HEAD -- || git diff-index HEAD -- || true; } 2>/dev/null | grep $'\n' -c
16011601
}
16021602

16031603
# shellcheck disable=SC2155
1604-
readonly GIT_DIRTY_FILES_BEFORE_INIT="$(list_dirty_files | grep $'\n' -c)"
1604+
readonly GIT_DIRTY_FILES_BEFORE_INIT="$(count_dirty_files)"
16051605

16061606
# perform function calls to configure transcrypt
16071607
get_cipher
@@ -1629,7 +1629,7 @@ fi
16291629

16301630
# check for newly modified (dirty) files after transcrypt configuration which could
16311631
# indicate an incorrect password
1632-
if [[ ${GIT_DIRTY_FILES_BEFORE_INIT} -lt $(list_dirty_files | grep $'\n' -c) ]]; then
1632+
if [[ ${GIT_DIRTY_FILES_BEFORE_INIT} -lt $(count_dirty_files) ]]; then
16331633
die 1 'Unexpected new dirty files in the repository when configured by transcrypt%s, please check your password.\n' "$CONTEXT_DESCRIPTION"
16341634
fi
16351635

0 commit comments

Comments
 (0)