Skip to content

Commit a96733f

Browse files
committed
Merge branch 'git-pre-commit-fix-always-slow-mode'
* git-pre-commit-fix-always-slow-mode: Document in changelog improvements by weichunglee in PR #197 fix logic for version checking in pre_commit, fix empty files always failing validate_file
2 parents 373a0b7 + aa3e96a commit a96733f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ system, you must also run the `--upgrade` command in each repository:
3434

3535
## [Unreleased]
3636

37+
### Fixed
38+
39+
- Fix pre-commit hook to use "fast" multi-threaded mode for Bash versions 5+ as
40+
well as 4.4+, and even if some encrypted files are empty (#197)
41+
3742
## [2.3.1] - 2025-02-24
3843

3944
### Fixed

transcrypt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,15 @@ git_pre_commit() {
392392
# Get prefix of raw file in Git's index using the :FILENAME revision syntax
393393
# The first bytes of an encrypted file are always "Salted" in Base64
394394
local firstbytes=$(git show :"${secret_file}" | head -c8)
395-
if [[ $firstbytes != "U2FsdGVk" ]]; then
395+
if [[ $firstbytes == "" ]]; then
396+
: # Do nothing
397+
elif [[ $firstbytes != "U2FsdGVk" ]]; then
396398
echo "true" >>"${tmp}"
397399
fi
398400
}
399401

400-
# if bash version is 4.4 or greater than fork to number of threads otherwise run normally
401-
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]] && [[ "${BASH_VERSINFO[1]}" -ge 4 ]]; then
402+
# if bash version is greater than or equal to 4.4, fork to number of threads otherwise run normally
403+
if [[ "${BASH_VERSINFO[0]}" -gt 4 ]] || { [[ "${BASH_VERSINFO[0]}" == 4 ]] && [[ "${BASH_VERSINFO[1]}" -ge 4 ]]; }; then
402404
num_procs=$(nproc)
403405
num_jobs="\j"
404406
for secret_file in $(_list_encrypted_files); do

0 commit comments

Comments
 (0)