@@ -170,23 +170,25 @@ _list_encrypted_files() {
170170 local strict_context=${1:- }
171171
172172 IFS=$' \n '
173- # List files with -z option to disable quoting of filenames, then
174- # immediately convert NUL-delimited filenames to be newline-delimited to be
175- # compatibility with bash variables
176- for file in $( git ls-files -z | tr ' \0' ' \n' ) ; do
177- # Check for the suffix ': filter: crypt' that identifies encrypted file
178- local check
179- check=$( git check-attr filter " $file " 2> /dev/null)
180-
181- # Only output names of encrypted files matching the context, either
182- # strictly (if $1 = "true") or loosely (if $1 is false or unset)
183- if [[ " $strict_context " == " true" ]] &&
184- [[ " $check " == * " : filter: crypt${CONTEXT_CRYPT_SUFFIX:- } " ]]; then
185- echo " $file "
186- elif [[ " $check " == * " : filter: crypt${CONTEXT_CRYPT_SUFFIX:- } " * ]]; then
187- echo " $file "
188- fi
189- done
173+ # List files with -z option to disable quoting of filenames, then filter
174+ # for files marked for encryption (git check-attr + grep), then only keep
175+ # filenames (sed) then evaluate escaped characters like double-quotes,
176+ # backslash and control characters (eval) which are part of the output
177+ # regardless of core.quotePath=false as per
178+ # https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath
179+ git -c core.quotePath=false ls-files -z | tr ' \0' ' \n' |
180+ git -c core.quotePath=false check-attr filter --stdin 2> /dev/null |
181+ {
182+ # Only output names of encrypted files matching the context, either
183+ # strictly (if $1 = "true") or loosely (if $1 is false or unset)
184+ if [[ " $strict_context " == " true" ]]; then
185+ grep " : filter: crypt${CONTEXT_CRYPT_SUFFIX:- } $" || true
186+ else
187+ grep " : filter: crypt${CONTEXT_CRYPT_SUFFIX:- } .*$" || true
188+ fi
189+ } |
190+ sed " s|: filter: crypt${CONTEXT_CRYPT_SUFFIX:- } .*||" |
191+ while read -r file; do eval " echo $file " ; done
190192}
191193
192194# Detect OpenSSL major version 3 or later which requires a compatibility
@@ -1035,7 +1037,14 @@ upgrade_transcrypt() {
10351037list_files () {
10361038 if [[ $IS_BARE == ' false' ]]; then
10371039 cd " $REPO " > /dev/null || die 1 ' could not change into the "%s" directory' " $REPO "
1038- _list_encrypted_files true
1040+
1041+ if [[ -z " $CONTEXT_CRYPT_SUFFIX " ]]; then
1042+ # Non-strict listing of files when context is unset / default
1043+ _list_encrypted_files
1044+ else
1045+ # Strict listing of files when a specific context is set
1046+ _list_encrypted_files true
1047+ fi
10391048 fi
10401049}
10411050
0 commit comments