From 0a0e0a0d47203220bf35e2243e46f68f6873cfbc Mon Sep 17 00:00:00 2001 From: Kareppa Hipparagi Date: Fri, 15 Dec 2023 13:02:01 +0530 Subject: [PATCH 1/2] Avoid scanning of entire repo when a file is deleted --- git-secrets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-secrets b/git-secrets index a2f16ac..d30b16a 100755 --- a/git-secrets +++ b/git-secrets @@ -176,6 +176,8 @@ pre_commit_hook() { while IFS= read -r file; do [ -n "$file" ] && files+=("$file") done <<< "$(git diff-index --diff-filter 'ACMU' --name-only --cached $rev --)" + # when the file list empty, then don't all the scan, otherwise it will start scanning entire repo + [ -z "${files[@]}" ] && return scan_with_fn_or_die "scan" "${files[@]}" } From f951e6e69dbaef2f1a0b3319335263514f1f47d4 Mon Sep 17 00:00:00 2001 From: Kareppa Hipparagi Date: Mon, 15 Apr 2024 14:10:04 +0530 Subject: [PATCH 2/2] Fix binary operator expected warning (#2) --- git-secrets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-secrets b/git-secrets index d30b16a..7079ae2 100755 --- a/git-secrets +++ b/git-secrets @@ -177,7 +177,7 @@ pre_commit_hook() { [ -n "$file" ] && files+=("$file") done <<< "$(git diff-index --diff-filter 'ACMU' --name-only --cached $rev --)" # when the file list empty, then don't all the scan, otherwise it will start scanning entire repo - [ -z "${files[@]}" ] && return + [[ -z "${files[@]}" ]] && return scan_with_fn_or_die "scan" "${files[@]}" }