simpleqt commented on code in PR #458:
URL: https://github.com/apache/commons-codec/pull/458#discussion_r4628545620
##########
src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java:
##########
@@ -219,7 +226,10 @@ private static FileMode get(final Path path) {
if (Files.isDirectory(path)) {
return DIRECTORY;
}
- if (Files.isExecutable(path)) {
+ // Windows reports every readable file as executable. Git records
the executable bit only where the file system
+ // provides POSIX permissions; elsewhere, for example with Git for
Windows and its default core.fileMode=false,
+ // regular files are stored as 100644.
+ if (Files.getFileAttributeView(path, PosixFileAttributeView.class)
!= null && Files.isExecutable(path)) {
Review Comment:
Done on `8e8a5d2` — thanks, this is cleaner than the three separate calls.
`FileMode.get` now reads one attribute set: it asks for the
`PosixFileAttributeView` with `NOFOLLOW_LINKS`, falls back to
`BasicFileAttributeView` when the file system has no POSIX view, classifies
with `attrs.isSymbolicLink()` / `attrs.isDirectory()`, and uses
`((PosixFileAttributes)
attrs).permissions().contains(PosixFilePermission.OWNER_EXECUTE)` for the
executable bit. `get` now declares `IOException`, which its only caller
(`populate`) already throws.
Local evidence on Windows 10 / JDK 17.0.11:
- the three non-symlink `GitIdentifiersTest` cases this change covers: 3
run, 0 failures
- full `mvn -B -ntp -o -Dmaven.repo.local=G:/pr/tools/m2local test`: 19971
run, 0 failures, 3 errors, 20 skipped — the 3 errors are the pre-existing
Windows symlink-privilege failures in `testBlobIdSymlink`/`testTreeIdPathUnix`,
unrelated to this change; the two GitIdentifiers Windows failures this PR fixes
are gone
The PR description now shows the attribute-view implementation. The PR is
still a draft; CI on the new head is `action_required` again, so the local run
is the only executed evidence.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]