Skip to content

npm run plugin:generate creates phantom git changes via stat cache invalidation #1029

@mattdot

Description

@mattdot

Description

Running npm run plugin:generate causes 22+ files to appear as modified in git status despite having identical content to HEAD. This creates noise in the working tree and can lead to accidental commits of no-op changes.

Steps to Reproduce

  1. Start with a clean working tree (git status shows no changes)
  2. Run npm run plugin:generate
  3. Run git status

Expected Behavior

Only files with actual content changes appear in git status.

Actual Behavior

22 files show as modified ( M) including all plugin.json and plugin README.md files. Running git diff on these files produces empty output — the content is byte-for-byte identical to HEAD.

Root Cause

The plugin generator script rewrites output files unconditionally (write-always pattern), even when the content hasn't changed. This updates filesystem timestamps (mtime/ctime), which invalidates git's index stat cache. With core.filemode=false (typical in devcontainers) and * text=auto in .gitattributes, git update-index --refresh fails to resolve the mismatch, leaving the files permanently marked as "needs update."

Affected Files

  • .github/plugin/marketplace.json
  • collections/hve-core-all.collection.yml
  • All plugins/*/README.md files (11 plugins)
  • All plugins/*/.github/plugin/plugin.json files (11 plugins)

Suggested Fix

Update the plugin generator to use a write-if-changed pattern: compute the new content, compare it to the existing file, and only write when the content differs. This avoids touching timestamps on unchanged files.

Workaround

Run git checkout -- <file> on the phantom files to reset the stat cache, or use:

git status --porcelain | grep '^ M' | awk '{print $2}' | xargs git checkout --

Environment

  • Dev container (Ubuntu 22.04)
  • core.filemode=false
  • .gitattributes: * text=auto

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions