From cb166478cbb508729d6d6a47e9668d09717897e6 Mon Sep 17 00:00:00 2001 From: Graham Borland Date: Tue, 6 Sep 2022 11:19:05 +0100 Subject: [PATCH 1/2] Add --binary when creating patch for unstaged files --- plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt index 607874ae..00f3878a 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt @@ -80,7 +80,7 @@ internal fun generateGitHook( echo "${'$'}CHANGED_FILES" diff=.git/unstaged-ktlint-git-hook.diff - git diff --color=never > ${'$'}diff + git diff --binary --color=never > ${'$'}diff if [ -s ${'$'}diff ]; then git apply -R ${'$'}diff fi From 543d2ef018951a7605f11aac2c03857d2381fca0 Mon Sep 17 00:00:00 2001 From: Graham Borland Date: Sat, 1 Apr 2023 11:42:23 +0100 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92ae5c0f..0e6b0b23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - fix new ktlint errors that come from our new default version of ktlint [#651](https://github.com/JLLeitschuh/ktlint-gradle/pull/651) - fix syntax bug in release logic for VERSION_LATEST_RELEASE.txt [#651](https://github.com/JLLeitschuh/ktlint-gradle/pull/651) +- fix the pre-commit hook to cope with unstaged binary files [#603](https://github.com/JLLeitschuh/ktlint-gradle/pull/603) ## [11.3.1] - 2023-03-03