-
Notifications
You must be signed in to change notification settings - Fork 497
Add null check for issue 911 #2770
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
Conversation
Pankraz76
left a comment
There was a problem hiding this 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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)) |
There was a problem hiding this comment.
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.
|
Proposed fix for issue 911.