Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The pre-commit Git hook adds files after checking them #330

Closed
petitJAM opened this issue Jan 30, 2020 · 3 comments · Fixed by #343
Closed

The pre-commit Git hook adds files after checking them #330

petitJAM opened this issue Jan 30, 2020 · 3 comments · Fixed by #343

Comments

@petitJAM
Copy link

This line of the pre-commit hook causes problems for me: https://github.com/JLLeitschuh/ktlint-gradle/blob/master/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt#L46

I frequently make commits that contain just hunks of a file using git add --patch (usually when I have several changes locally that I want to split into separate commits). When the pre-commit runs on files where I've done that, it blindly stages the rest of the file, changing what I was committing.

My guess is that this is needed for the ktlintFormat pre-commit hook to add any changes made into the commit. However, I believe this is not needed for the ktlintCheck pre-commit hook (which is what I'm using), since it does not change any files.

I've fixed this for myself by simply removing that loop from the hook.

@Tapchicoma
Copy link
Collaborator

Makes sense, will remove git add call for ktlintCheck pre-commit hook.

@JLLeitschuh
Copy link
Owner

Was this resolved?

@Tapchicoma
Copy link
Collaborator

no, most probably in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants