File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ system, you must also run the `--upgrade` command in each repository:
3434
3535## [ Unreleased]
3636
37+ ### Changed
38+
39+ - Improve check for incorrect password to avoid false report when transcrypt
40+ init is run with --force in a repo containing dirty files (#196 )
41+
3742### Fixed
3843
3944- Fix pre-commit hook to use "fast" multi-threaded mode for Bash versions 5+ as
Original file line number Diff line number Diff line change @@ -1596,6 +1596,13 @@ elif [[ $cipher ]]; then
15961596 validate_cipher
15971597fi
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
1601+ }
1602+
1603+ # shellcheck disable=SC2155
1604+ readonly GIT_DIRTY_FILES_BEFORE_INIT=" $( list_dirty_files | grep $' \n ' -c) "
1605+
15991606# perform function calls to configure transcrypt
16001607get_cipher
16011608get_password
@@ -1620,12 +1627,10 @@ if [[ ! -f $GIT_ATTRIBUTES ]]; then
16201627 printf ' #pattern filter=crypt diff=crypt merge=crypt\n' > " $GIT_ATTRIBUTES "
16211628fi
16221629
1623- # check for modified (dirty) files after transcrypt configuration which could
1630+ # check for newly modified (dirty) files after transcrypt configuration which could
16241631# indicate an incorrect password
1625- #
1626- # check if the repo is dirty
1627- if git status --porcelain 2> /dev/null | grep " ^ M" > /dev/null; then
1628- die 1 ' Unexpected dirty files in the repository when configured by transcrypt%s, check your password.\n' " $CONTEXT_DESCRIPTION "
1632+ if [[ ${GIT_DIRTY_FILES_BEFORE_INIT} -lt $( list_dirty_files | grep $' \n ' -c) ]]; then
1633+ die 1 ' Unexpected new dirty files in the repository when configured by transcrypt%s, please check your password.\n' " $CONTEXT_DESCRIPTION "
16291634fi
16301635
16311636printf ' The repository has been successfully configured by transcrypt%s.\n' " $CONTEXT_DESCRIPTION "
You can’t perform that action at this time.
0 commit comments