@@ -173,20 +173,25 @@ _list_encrypted_files() {
173173 # List files with -z option to disable quoting of filenames, then
174174 # immediately convert NUL-delimited filenames to be newline-delimited to be
175175 # 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
176+ # List files with -z option to disable quoting of filenames,
177+ # then filter for files marked for encryption (git check-attr + grep),
178+ # then only keep filenames (sed)
179+ # then evaluate escaped characters like double-quotes, backslash and control characters (eval)
180+ # which are part of the output regardless of core.quotePath=false as per
181+ # https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath
182+ git -c core.quotePath=false ls-files -z | tr ' \0' ' \n' |
183+ git -c core.quotePath=false check-attr filter --stdin 2> /dev/null |
184+ {
185+ # Only output names of encrypted files matching the context, either
186+ # strictly (if $1 = "true") or loosely (if $1 is false or unset)
187+ if [[ " $strict_context " == " true" ]]; then
188+ grep " : filter: crypt${CONTEXT_CRYPT_SUFFIX:- } $" || true
189+ else
190+ grep " : filter: crypt${CONTEXT_CRYPT_SUFFIX:- } .*$" || true
191+ fi
192+ } |
193+ sed " s|: filter: crypt${CONTEXT_CRYPT_SUFFIX:- } .*||" |
194+ while read -r file; do eval " echo $file " ; done
190195}
191196
192197# Detect OpenSSL major version 3 or later which requires a compatibility
@@ -1035,7 +1040,14 @@ upgrade_transcrypt() {
10351040list_files () {
10361041 if [[ $IS_BARE == ' false' ]]; then
10371042 cd " $REPO " > /dev/null || die 1 ' could not change into the "%s" directory' " $REPO "
1038- _list_encrypted_files true
1043+
1044+ if [[ -z " $CONTEXT_CRYPT_SUFFIX " ]]; then
1045+ # Non-strict listing of files when context is unset / default
1046+ _list_encrypted_files
1047+ else
1048+ # Strict listing of files when a specific context is set
1049+ _list_encrypted_files true
1050+ fi
10391051 fi
10401052}
10411053
0 commit comments