Skip to content

Commit

Permalink
Fix problem that pre_commit_hook passes multiple args as single arg
Browse files Browse the repository at this point in the history
-  not to use `readarray` built-in func (consider bash 3.x)
  • Loading branch information
t13a committed Feb 3, 2018
1 parent 89b311c commit 0b07dbe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions git-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,13 @@ commit_msg_hook() {
# Scans all files that are about to be committed.
pre_commit_hook() {
SCAN_CACHED=1
local file found_match=0 rev="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
local files=() file found_match=0 rev="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
# Diff against HEAD if this is not the first commit in the repo.
git rev-parse --verify HEAD >/dev/null 2>&1 && rev="HEAD"
# Filter out deleted files using --diff-filter
readarray -t files <<< $(git diff-index --diff-filter 'ACMU' --name-only --cached $rev --)
while IFS= read -r file; do
files+=("$file")
done <<< "$(git diff-index --diff-filter 'ACMU' --name-only --cached $rev --)"
scan_with_fn_or_die "scan" "${files[@]}"
}

Expand Down

0 comments on commit 0b07dbe

Please sign in to comment.