diff --git a/transcrypt b/transcrypt index ef6ca15..52d8dff 100755 --- a/transcrypt +++ b/transcrypt @@ -173,20 +173,17 @@ _list_encrypted_files() { # List files with -z option to disable quoting of filenames, then # immediately convert NUL-delimited filenames to be newline-delimited to be # compatibility with bash variables - for file in $(git ls-files -z | tr '\0' '\n'); do - # Check for the suffix ': filter: crypt' that identifies encrypted file - local check - check=$(git check-attr filter "$file" 2>/dev/null) - - # Only output names of encrypted files matching the context, either - # strictly (if $1 = "true") or loosely (if $1 is false or unset) - if [[ "$strict_context" == "true" ]] && - [[ "$check" == *": filter: crypt${CONTEXT_CRYPT_SUFFIX:-}" ]]; then - echo "$file" - elif [[ "$check" == *": filter: crypt${CONTEXT_CRYPT_SUFFIX:-}"* ]]; then - echo "$file" - fi - done + git -c core.quotePath=false ls-files -z | tr '\0' '\n' | + git -c core.quotePath=false check-attr filter --stdin 2>/dev/null | + { + if [[ "$strict_context" == "true" ]]; then + grep ": filter: crypt${CONTEXT_CRYPT_SUFFIX:-}$" || true + else + grep ": filter: crypt${CONTEXT_CRYPT_SUFFIX:-}.*$" || true + fi + } | + sed "s|: filter: crypt${CONTEXT_CRYPT_SUFFIX:-}.*||" | + while read -r file; do eval "echo $file"; done } # Detect OpenSSL major version 3 or later which requires a compatibility