Skip to content

Commit 0b07dbe

Browse files
committed
Fix problem that pre_commit_hook passes multiple args as single arg
- not to use `readarray` built-in func (consider bash 3.x)
1 parent 89b311c commit 0b07dbe

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

git-secrets

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@ commit_msg_hook() {
169169
# Scans all files that are about to be committed.
170170
pre_commit_hook() {
171171
SCAN_CACHED=1
172-
local file found_match=0 rev="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
172+
local files=() file found_match=0 rev="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
173173
# Diff against HEAD if this is not the first commit in the repo.
174174
git rev-parse --verify HEAD >/dev/null 2>&1 && rev="HEAD"
175175
# Filter out deleted files using --diff-filter
176-
readarray -t files <<< $(git diff-index --diff-filter 'ACMU' --name-only --cached $rev --)
176+
while IFS= read -r file; do
177+
files+=("$file")
178+
done <<< "$(git diff-index --diff-filter 'ACMU' --name-only --cached $rev --)"
177179
scan_with_fn_or_die "scan" "${files[@]}"
178180
}
179181

0 commit comments

Comments
 (0)