Skip to content

Avoid running git diff repeatedly #1327

@JelleZijlstra

Description

@JelleZijlstra

Summary

I was exploring prek on a huge work repo (tens of thousands of files) and noticed that it's about 3x slower than pre-commit. Looking at the trace log revealed that prek seems to be running git diff once per hook. Usually that would be fast but for us it often takes a few seconds, and that adds up when there's a few dozen hooks.

Could you instead run git diff once per invocation and reuse the result among hooks?

Platform

Darwin 25.2.0

Version

0.2.27

.pre-commit-config.yaml

No response

Log file

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions