diff --git a/CHANGES.md b/CHANGES.md index d3bb7eacf1..c9825f6de4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Changes * Bump default `ktlint` version to latest `1.7.1` -> `1.8.0`. ([2763](https://github.com/diffplug/spotless/pull/2763)) * Bump default `gherkin-utils` version to latest `9.2.0` -> `10.0.0`. ([#2619](https://github.com/diffplug/spotless/pull/2619)) +- Fix null pointer exception when git ignored files are checked in ([911](https://github.com/diffplug/spotless/issues/911)) ## [4.1.0] - 2025-11-18 ### Changes diff --git a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitRatchet.java b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitRatchet.java index f30e8fd002..3d90fcc9e4 100644 --- a/lib-extra/src/main/java/com/diffplug/spotless/extra/GitRatchet.java +++ b/lib-extra/src/main/java/com/diffplug/spotless/extra/GitRatchet.java @@ -97,8 +97,14 @@ public boolean isClean(Project project, ObjectId treeSha, String relativePathUni WorkingTreeIterator workingTreeIterator = treeWalk.getTree(WORKDIR, WorkingTreeIterator.class); boolean hasTree = treeIterator != null; + boolean hasWorkingTree = workingTreeIterator != null; boolean hasDirCache = dirCacheIterator != null; + if (!hasWorkingTree) { + // Null check for issue 911 + return true; + } + if (!hasTree) { // it's not in the tree, so it was added return false; diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 76832c1b22..bd3d1968d4 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -8,6 +8,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Changes * Bump default `ktlint` version to latest `1.7.1` -> `1.8.0`. ([2763](https://github.com/diffplug/spotless/pull/2763)) * Bump default `gherkin-utils` version to latest `9.2.0` -> `10.0.0`. ([#2619](https://github.com/diffplug/spotless/pull/2619)) +- Fix null pointer exception when git ignored files are checked in ([911](https://github.com/diffplug/spotless/issues/911)) ## [8.1.0] - 2025-11-18 ### Changes diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 6be35513a3..fca279729d 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -8,6 +8,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Changes * Bump default `ktlint` version to latest `1.7.1` -> `1.8.0`. ([2763](https://github.com/diffplug/spotless/pull/2763)) * Bump default `gherkin-utils` version to latest `9.2.0` -> `10.0.0`. ([#2619](https://github.com/diffplug/spotless/pull/2619)) +- Fix null pointer exception when git ignored files are checked in ([911](https://github.com/diffplug/spotless/issues/911)) ## [3.1.0] - 2025-11-18 ### Changes