Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance: don't create subshells #193

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions transcrypt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading