bug(gitignore): the anchored user-layer rules switch off every negation beneath them
What happened
https://github.com/career-ops-hq/career-ops/pull/4555 added a root-anchored rule above each user-layer block:
/data
data/*
!data/.gitkeep
!data/offers/
!data/parser-output/That fixes the symlink escape it set out to fix. It also switches off every negation beneath it. Git does not descend into an excluded directory, so once /data matches the directory itself, !data/.gitkeep, !data/offers/ and !data/parser-output/ stop applying. The same holds for !output/.gitkeep, !jds/.gitkeep, !documents/.gitkeep and !documents/README.md.
On current main, asking the pattern question directly:
$ git check-ignore --no-index -v data/.gitkeep
.gitignore:11:/data data/.gitkeep
$ git ls-files -ci --exclude-standard
data/.gitkeep
data/offers/.gitkeep
data/parser-output/.gitkeep
documents/.gitkeep
documents/README.md
jds/.gitkeep
output/.gitkeepSeven tracked system scaffolds are now claimed by the ignore rules.
Why CI did not catch it
tests/user-layer-untracked.test.mjs and the new symlink suite both check that these paths remain tracked, using git ls-files --error-unmatch. .gitignore has no effect on a tracked file, so that assertion is true either way and cannot fail here. It is why the allowlist in that suite had to grow when the rule landed, rather than the rule being reconsidered.
Nothing breaks in a working tree today. It surfaces on a fresh scaffold, or after someone removes and restores data/offers/, at which point the placeholder cannot be re-added.
The fix
Pair each anchored rule with a trailing-slash negation. A trailing slash matches directories only, and a symlink is not a directory to git, so the negation re-includes a real directory and leaves a link ignored:
/data
!data/
data/*Measured three ways, data as a symlink to a real directory holding real files:
rules target check-ignore git add -An status -uall
/data symlink IGNORED 0 paths 0 paths
/data then !data/ symlink IGNORED 0 paths 0 pathsand on a real directory:
rules target data/.gitkeep data/offers/.gitkeep
/data real dir IGNORED IGNORED
/data then !data/ real dir tracked trackedOrder is load-bearing. !data/ before /data fails, and !data without the slash reopens the symlink hole.
Source: santifer/career-ops