Repository navigation
GitIdentifiers: record files as regular without POSIX permissions - #458
Merged
Merged
Conversation
garydgregory
requested changes
Nov 15, 2026
garydgregory
marked this pull request as draft
November 15, 2026 16:22
Member
|
Convert to draft until review. |
simpleqt
force-pushed
the
gitidentifiers-exec-bit
branch
from
November 16, 2026 11:23
194f644 to
fa2997c
Compare
ppkarwasz
reviewed
Nov 18, 2026
Files.isExecutable(Path) returns true for every readable file on the default Windows file system, so treeId(Path) recorded all regular files with mode 100755 instead of 100644 and produced tree identifiers that differ from Git's. Git records the executable bit only where the file system exposes POSIX permissions; with its default core.fileMode=false on Windows it stores regular files as 100644. The executable bit is now used only when the file has a POSIX attribute view. On a POSIX file system the view is present and Files.isExecutable stays authoritative, so the behaviour there is unchanged. Add a regression test. Existing GitIdentifiersTest.testTreeIdPath and testTreeIdSortsSupplementaryPlaneNamesLikeGit now pass on Windows. Assisted-By: DeepSeek dsv41
simpleqt
force-pushed
the
gitidentifiers-exec-bit
branch
from
November 19, 2026 12:13
fa2997c to
8e8a5d2
Compare
ppkarwasz
reviewed
Nov 20, 2026
Address the review nit on FileMode.get: read one BasicFileAttributeView (POSIX preferred, Basic fallback), classify symbolic link and directory once, and use an instanceof PosixFileAttributes check for the owner-execute bit. This removes the duplicated fallback classification. The executable bit is still only read where the file system exposes POSIX permissions; without a POSIX view the attributes are BasicFileAttributes and the file is REGULAR.
garydgregory
marked this pull request as ready for review
November 21, 2026 15:53
garydgregory
added a commit
that referenced
this pull request
Nov 21, 2026
ppkarwasz
approved these changes
Nov 21, 2026
Comment on lines
+227
to
+231
| // Read one attribute set, preferring POSIX where the file system provides it. The basic view always exists and | ||
| // classifies links and directories; only POSIX permissions carry the owner-execute bit that Git records. Git | ||
| // records the executable bit only where the file system exposes POSIX permissions; elsewhere, for example with | ||
| // Git for Windows and its default core.fileMode=false, regular files are stored as 100644 even though Windows | ||
| // reports every readable file as executable. |
Member
There was a problem hiding this comment.
Nit: I think the code is self-explaining, so this comment could be dropped. LLMs have the tendency of writing the history of their life as comments, but IMHO most of them are not necessary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitIdentifiers.treeId(Path)records every file as mode100755on Windows, so the tree identifiers it computes do not match Git's.Files.isExecutable(Path)is the only test used to choose between100644and100755, and on the default Windows file system every readable file reports as executable. Git records the executable bit only where the file system exposes POSIX permissions; with its defaultcore.fileMode=falseon Windows, every regular file is stored as100644. The same applies to any file system without POSIX permissions.The mode is now classified from one attribute set, preferring the POSIX view where the file system provides it and falling back to the basic view elsewhere:
attrs.isSymbolicLink()andattrs.isDirectory()classify the entry, and only the POSIX permission bits carry the owner-execute bit Git records. On a POSIX file system the POSIX view is present, so the executable bit is used exactly as before; on a file system without it the file is100644. This also replaces the separateFiles.isSymbolicLink/isDirectory/isExecutablecalls with one attribute read, following the review suggestion.Test
GitIdentifiersTest.testTreeIdPathRecordsFilesWithoutPosixExecutableBitAsRegularcomparesGitIdentifiers.treeId(Path)on a temporary directory with a tree built throughTreeIdBuilder, so it fails while the path-based tree still uses the executable bit for an ordinary file. Two existing tests,testTreeIdPathandtestTreeIdSortsSupplementaryPlaneNamesLikeGit, fail on Windows for the same reason and pass with the change.Local results on Windows 10, JDK 17.0.11,
mvn -B -o -Dtest=GitIdentifiersTest test:testTreeIdPath,testTreeIdPathRecordsFilesWithoutPosixExecutableBitAsRegular,testTreeIdSortsSupplementaryPlaneNamesLikeGit), plus 3 errors from the symlink tests that need a Windows privilege this host does not havetestTreeIdPath,testTreeIdSortsSupplementaryPlaneNamesLikeGit,testTreeIdPathRecordsFilesWithoutPosixExecutableBitAsRegular): 3 run, 0 failuresmvn -B -ntp -o -Dmaven.repo.local=G:/pr/tools/m2local test: 19971 run, 0 failures, 3 errors (the same Windows symlink-privilege errors), 20 skippedLinux and macOS CI are the first runs on a POSIX file system; the changed branch is a single guard, and the POSIX path keeps its previous behaviour. CI on this repository is currently
action_required(first contribution from this fork), so the numbers above are local only.The commit carries an
Assisted-By:trailer, asAGENTS.mdasks.