Skip to content

Conversation

@Gene-R-Pool
Copy link

Proposed fix for issue 911.

Copy link
Contributor

@Pankraz76 Pankraz76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one, that´s how its supposed to be done.

Could you reproduce and might test the issue?

Thanks.

// it's not in the tree, so it was added
return false;
} else {
if (hasDirCache) {
Copy link
Contributor

@Pankraz76 Pankraz76 Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (hasDirCache && workingTreeIterator != null) {

this would also fix the NPE but with potentially different outcome using the default else case. idk whats the difference.
using fallback in L:123 or early exit.

// no dirCache, so we will compare the tree to the workdir manually

DirCacheIterator dirCacheIterator = treeWalk.getTree(INDEX, DirCacheIterator.class);
WorkingTreeIterator workingTreeIterator = treeWalk.getTree(WORKDIR, WorkingTreeIterator.class);

boolean hasTree = treeIterator != null;
Copy link
Contributor

@Pankraz76 Pankraz76 Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
boolean hasTree = treeIterator != null;
boolean hasTree = treeIterator != null && workingTreeIterator != null;

would also do the trick, calling the else case.

Ned should make the the call on this. Im just pointing out ideas. Thanks.

### 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))
Copy link
Contributor

@Pankraz76 Pankraz76 Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

considering fixed block.

### Fixed

Thanks for your good template. it was simple to continue thanks to your contribution.

@nedtwigg
Copy link
Member

@nedtwigg nedtwigg closed this Nov 27, 2025
nedtwigg added a commit that referenced this pull request Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants