awslabs / awslabs/git-secrets

"git commit --amend" scans entire working directory if no files are staged

Open
#129 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
13.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

When "git commit --amend" is used when no files are staged (for example, to reword a commit message), git-secrets --pre_commit_hook scans the entire working tree. This is because the scan() function is called with an empty file list.

For large repos, this causes a bad user experience; the user expects their editor to open immediately, but instead the pre-commit hook runs for multiple seconds (9 seconds in the linux kernel on my workstation), with no progress indication. If the repo contains any previously committed files that match git-secrets patterns, the editor never opens, and git-secrets' error message is displayed.

We can make the pre_commit_hook() function return immediately if there are no changed files, which should match user expectations.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.