Skip to content

Avoid overwriting unchanged hooks #4865

@RuxandraM

Description

@RuxandraM

Describe the issue
We came across a timestamp issue regarding git hooks. We have a custom set-up for our git repository, where we changed .git/hooks to be a symlink pointing to a tracked folder inside the repository. This is because we want to track the differences to the hooks in the repo. When filter-process is triggered, git-lfs is trying to overwrite the hooks. The files are identical, so git-lfs is overwriting them with the same contents, resulting in a timestamp change. This is picked up as a difference by commands like git diff-files. Normally, this is not a problem because we update the index, however, I've seen cases of the filter-process being triggered right after git update-index --refresh, or after git status. So we noticed that we were updating the index, then immediately saw differences that were not expected, because the timestamp of the hook files was changed.

I tried to reproduce this here

Any thoughts? Is it possible to skip writing the hook files if they are identical? I understand git-lfs checks for the contents anyway (for not overwriting custom hooks).

System environment
Running on MacOS, git-lfs/2.13.3, git version 2.23.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions