Skip to content

Disable filesystem timestamp resolution persistence to JGit config#9

Merged
kmccarp merged 1 commit intomainfrom
kmccarp/disable-jgit-config-persistence
Mar 2, 2026
Merged

Disable filesystem timestamp resolution persistence to JGit config#9
kmccarp merged 1 commit intomainfrom
kmccarp/disable-jgit-config-persistence

Conversation

@kmccarp
Copy link
Contributor

@kmccarp kmccarp commented Feb 26, 2026

Background / Problem

FileStoreAttributes.saveToConfig() persists filesystem timestamp resolution measurements to the JGit config file (~/.config/jgit/config). When user.home resolves to a relative or invalid path (e.g. "?" on JDK 8-18 in containers without a /etc/passwd entry for the running UID — see JDK-8280357), this creates a config file inside the repository working directory. The file then gets picked up during working tree traversal and included in build outputs.

On Windows, the ? character is illegal in file paths, so processing these build outputs fails with InvalidPathException.

Solution

Make saveToConfig() a no-op. The in-memory FileStoreAttributes cache is sufficient for the lifetime of a JVM process. The only cost is re-measuring filesystem timestamp resolution on the next JVM start, which is fast. This eliminates the possibility of JGit polluting the working tree regardless of what user.home resolves to.

When user.home resolves to a relative or invalid path (e.g. "?" on
JDK 8-18 in containers without a /etc/passwd entry for the running
UID), FileStoreAttributes.saveToConfig() creates a config file
inside the working directory. This pollutes the repository working
tree, and the file ends up in the LST manifest. On Windows, the "?"
character is illegal in paths, causing InvalidPathException when
processing the LST.

The in-memory FileStoreAttributes cache is sufficient for the
lifetime of a JVM process. The only cost of not persisting is
re-measuring filesystem timestamp resolution on the next JVM start,
which is fast.
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Feb 26, 2026
@kmccarp kmccarp merged commit a70606c into main Mar 2, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Mar 2, 2026
@kmccarp kmccarp deleted the kmccarp/disable-jgit-config-persistence branch March 2, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant