Skip to content

session: a land with a filter program works on Apple Git 2.39 (git-lfs on macOS) - #2035

Merged
AbirAbbas merged 5 commits into
app/v3from
fix/land-apple-git-attributes
Nov 2, 2026
Merged

AbirAbbas merged 5 commits into
app/v3from
fix/land-apple-git-attributes

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Why

On macOS, landing a task branch from the desktop app refused every land whenever any filter.<driver>.clean|smudge|process program was configured. git lfs install writes exactly that into ~/.gitconfig, so anyone with git-lfs installed could not land at all, even in a repository where no file uses LFS. The refusal read "this land cannot determine which files run a filter program".

The cause is Apple Git 2.39.5, which is what the app gets from a Finder-launched PATH (/usr/bin/git). The land's attribute checks (#1995) use two newer Git interfaces:

  • git var GIT_ATTR_GLOBAL / GIT_ATTR_SYSTEM (Git 2.42). Apple Git answers usage: git var (-l | <variable>), exit 129.
  • git check-attr --source=<tree> (Git 2.40). Apple Git answers error: unknown option `source=…', exit 129.

Measured on the Mac (macOS 15.6, Apple Git-154): 4 land tests fail there for this reason alone (TestAnUnusedFilterDoesNotRefuseALand, TestAUsedFilterRefusesALandWithItsPaths, TestFilterFactsChangingAfterAPlanRefuseTheLand, TestConfigurationALandWillNotMergeUnder).

Change

#1995's rule is unchanged: a land refuses only when its paths carry a filter whose driver has a program. With no program configured, the land still asks Git nothing about attributes and starts no new process.

With a program configured, the land now works out per Git executable whether the newer queries are unsupported, and falls back when they are. It caches the answer, keyed by the executable's path and file identity and its exact git version line. /usr/bin/git is an xcrun shim whose own file does not change when xcode-select picks another Git, which is why the version line is part of the key.

  • When a query counts as unsupported. Git's reply must be the whole unsupported reply (git var's usage line; check-attr's unknown-option line for this exact --source, followed by its usage block), with exit 129 and no output, and the version must predate the query. Anything else still refuses: a warning, a truncated reply, an unexpected exit, a timeout. Transient failures are never cached. Vendor backports keep the native query.

  • Tree attributes (fallback). Each tree is read into a fresh index inside a private temporary directory outside the repository (GIT_INDEX_FILE after the land's GIT_* scrub, read-tree, then check-attr --cached). Split index and hooks are off, and the directory is removed before the plan returns. The answer goes through the same record validation and hashing as before. A TMPDIR inside the checkout refuses.

  • Attribute files (fallback). The global file is found the way Git finds it: git config --null --path --get core.attributesFile, else $XDG_CONFIG_HOME/git/attributes, else $HOME/.config/git/attributes, read from the environment the git child actually gets. Apple Git's two system files are bound, honouring GIT_ATTR_NOSYSTEM:

    • %(prefix)/share/git-core/gitattributes, expanded by Git itself;
    • /etc/gitattributes.

    This is the layout from Apple's own source (apple-oss-distributions/Git, attr.c in Git-146 through Git-155, with ETC_GITATTRIBUTES=/etc/gitattributes in its Makefile). A non-Apple Git older than 2.42 cannot name its compiled system file, so it still refuses, as before.

  • Capable Git (Linux CI, ≥ 2.42). It keeps the native queries in the same order, and the plan's attribute digest has the same bytes.

  • Docs. The manual's land section is updated, and a change entry is added.

The attribute reading is also split into one job per function. The task engine's complexity law (TestNoRoadInTheTaskEngineHasMoreEndingsThanItsLedgerRow) holds task*.go functions to 15 decisions, and #1995 had left landAttributeFiles (22) and landFilterAttributes (18) over it. Every function in task_branch_land_filter.go is now at or under the ceiling, so this PR takes two complaints off that test instead of adding any. The split changes no behaviour: the same repository planned by the engine before and after the split gets a byte-identical plan revision.

Not changed: merge-driver, sparse and merge-option refusals; the 8 MiB bounds; plan/land revalidation. Apple Git 2.50's native git var GIT_ATTR_SYSTEM names only /etc/gitattributes and not Apple's second system file. That only narrows the raw-file binding (the answers still include it), and this PR leaves it as it is.

Tests

New, in internal/session/task_branch_land_filter_test.go:

  • TestALandFallsBackWhenAttributeQueriesAreUnavailable
    • The source query unsupported, the files query unsupported, and both.
    • A realistic git lfs install config that no path uses lands.
    • A clean, smudge or process filter used from the task, target or base tree refuses with the exact path, and the filter never runs.
    • Modern versions that give the same replies refuse, and so does a non-Apple 2.39.
  • TestALandReadsEachTreesAttributesWithoutTheCheckout
    • Nested attributes, a macro, and contradicting checkout attributes.
    • Where the host Git has --source, the fallback digest must equal the native digest.
  • TestALandResolvesLegacyAttributeFiles
    • core.attributesFile given as absolute, relative, ~/, with whitespace, and empty; then XDG, and empty XDG.
    • Each bound file is proved bound: an edit that changes no answer refuses changed. An unbound file is proved unbound.
    • Apple's system files, and GIT_ATTR_NOSYSTEM parsing (last value wins).
  • TestALandsTemporaryIndexLeavesTheRepositoryUntouched
    • core.splitIndex=true and a post-index-change hook are in place, and the hook never runs.
    • No sharedindex.* or index.lock appears, and the real index bytes are unchanged.
    • No scratch is left after success, refusal or cancellation.
  • TestALandRefusesScratchInsideTheRepository
  • TestALandCachesOnlyAttributeCapabilities
    • Repeated plans skip the failing queries, and a new executable path is probed again.
    • A version switch behind an unchanged shim is not taken from the cache.
    • Warning, truncated, wrong-source and extra-line replies, and transient failures, refuse and are not cached.
  • TestALandRefusesWhenFallbackAttributesAreUnknown
    • A failing, warning or noisy read-tree, and an incomplete, malformed or oversized cached answer, all refuse.

Changed: TestUnknownFilterAttributesRefuseALand's "old attribute-file query" case now also reports a modern version, so it stays a refusal on every host. TestALandWithNoFilterProgramNeverAsksAboutAttributes also catches the new read-tree, config, version and probe calls.

Gates (on the Mac, Apple Git 2.39.5, Go 1.26.5)

  • gofmt; go vet ./internal/session on darwin, GOOS=linux and GOOS=windows: clean.
  • All tests in task_branch_land*_test.go (the darwin-buildable ones), plus the two manual-reading tests in internal/session: pass. The 4 R3 tests failed before this change and pass after it.
  • -race on the cache, fallback, scratch and temporary-index tests: pass.
  • Law tests (internal/commentlaw, internal/guard and the two complexity laws) were run on app/v3 and on this branch and compared by content: no new complaint, and two fewer (above).
  • cmd/codeaf land tests (TestABranchLandsOnceOnTheConfirmedPlan and the 3 others): pass. internal/manual/...: pass.
  • Full Mac gate, go test -count=1 -p 6 ./..., compared by test name with the Mac baseline for app/v3 12dadd6: pending (queued behind the machine-wide heavy-job lock, which waits for the Mac performance baseline).
  • Engine CI dispatched on this branch (head 1a060c3), judged by content against app/v3 12dadd6's fresh runs (PR gate 40925411112, Full check 40925415150):
    • PR gate 40938668896: the light gate's output is identical to app/v3's, except that the two task_branch_land_filter.go complexity complaints are gone. The touched internal/session run fails only on app/v3's known failures.
    • Full check 40938673780: 26 failures, all among app/v3's known failures (the 2 it lacks are known-flaky there). All land tests pass on CI's Linux Git, including the native-versus-fallback digest comparison that cannot run on Apple Git.

Manual verification (real engine, desktop wire)

On an isolated codeaf home and an isolated user HOME, the real codeaf app was driven over the desktop's JSON-lines protocol (agents.create, then branches.land.plan, then branches.land). The repository had a recorded task branch, the git was Apple Git 2.39.5, and git-lfs 3.8.0's git lfs install had written the real [filter "lfs"] block into that HOME's .gitconfig:

Case app/v3 engine this branch
lfs installed, no file uses it refused: "this land cannot determine which files run a filter program" landed (merge commit), ~290 ms plan
lfs installed, the task adds big.bin under *.bin filter=lfs (a real LFS pointer) refused: "cannot determine…", no paths refused filter, paths ["big.bin"]; nothing ran, HEAD unchanged
no filter program landed landed

No codeaf-land-attributes-* directory was left behind. Not verified: the desktop window's own Land button, because this Mac has no screen access for the test session; the button drives these same two wire methods.

Review

There were three adversarial Codex review rounds.

  • Round 1 found 3 major issues, all fixed in the second commit:
    • The shim identity was reused across xcode-select switches.
    • Prefix-only unsupported matching accepted trailing warnings.
    • The scratch directory could sit inside the repository when TMPDIR pointed there.
  • Round 1 also found 3 minor issues: Windows skip order, a native comparison that could pass vacuously, and the missing change entry. All are fixed.
  • Round 2 found 2 more major issues, both fixed in the third commit, and each new test failed on the round-2 code before the fix:
    • A TMPDIR naming the checkout in another case on APFS slipped past the name-based containment. Containment now compares directory identities.
    • A bare usage line, or an indented warning, still matched the check-attr reply. The reply must now equal Apple Git 2.39.5's exact output.
  • Round 3: no blocker or major.
  • The function split came afterwards and is behaviour-preserving, checked by the identical plan revision and the full land suite.

🤖 Generated with Claude Code

AbirAbbas added a commit that referenced this pull request Oct 29, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
AbirAbbas added a commit that referenced this pull request Oct 29, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AbirAbbas
AbirAbbas force-pushed the fix/land-apple-git-attributes branch from 1a060c3 to c129ad2 Compare October 29, 2026 23:19
@AbirAbbas

Copy link
Copy Markdown
Collaborator Author

Closing unmerged: the Mac push stopped early to save usage. What this fixes and what is left is tracked in #2051. The branch fix/land-apple-git-attributes is kept.

@AbirAbbas AbirAbbas closed this Oct 29, 2026
@AbirAbbas AbirAbbas reopened this Nov 2, 2026
AbirAbbas added a commit that referenced this pull request Nov 2, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AbirAbbas
AbirAbbas force-pushed the fix/land-apple-git-attributes branch from c129ad2 to de751f5 Compare November 2, 2026 13:35
AbirAbbas and others added 5 commits November 2, 2026 10:45
With any filter.<driver>.clean|smudge|process configured (git lfs install
writes one), every land refused on macOS's own Git 2.39.5: the land asked
git var GIT_ATTR_GLOBAL/GIT_ATTR_SYSTEM (Git 2.42) and check-attr --source
(Git 2.40), and Apple Git rejects both.

The land now learns, once per git executable, whether those queries are
unsupported (the exact unsupported answer from a Git that predates them) and
then falls back:
- each tree's attributes come from a private temporary index outside the
  repository (read-tree, then check-attr --cached), with split index and
  hooks off, removed before the plan returns;
- the global attribute file is found the way Git finds it
  (core.attributesFile, else XDG_CONFIG_HOME or HOME), and Apple Git's two
  system files are bound, honouring GIT_ATTR_NOSYSTEM.
A capable Git keeps the native queries and the same plan digest. A non-Apple
Git that cannot name its system file still refuses. With no filter program
the land still asks Git nothing about attributes (#1995).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…xact unsupported replies

Review round 1 of the Apple Git fallback:
- /usr/bin/git on macOS is an xcrun shim whose own file does not change when
  xcode-select picks another Git, so the capability cache now keys on the
  exact `git version` line as well as the executable's identity.
- An unsupported reply counts only when it is the whole reply a Git that
  predates the query prints (git var's usage line; check-attr's unknown
  --source option for this source and its usage block), so a warning or a
  truncated answer refuses and is never cached.
- The scratch index refuses when TMPDIR points into the checkout.
- The new tests skip on Windows before building fixtures, and the native
  versus fallback comparison runs whenever the host Git has the query.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…f the checkout by identity

Review round 2:
- check-attr's unsupported reply must now equal the exact reply a Git that
  predates --source prints (the unknown-option line for this source and the
  whole usage block, measured on Apple Git 2.39.5). A bare usage line or an
  indented warning no longer passes and gets cached.
- The scratch directory's ancestors are compared with the checkout root by
  file identity, so a TMPDIR that names the checkout in another case on a
  case-insensitive volume refuses before any temporary index is written.
- The native half of the native-versus-fallback test fails if it fell back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The task engine's complexity law holds every function in task*.go to 15
decisions. #1995 left landAttributeFiles and landFilterAttributes over it,
and the Apple Git fallback had pushed three more functions past it. The
reading is now split along its own phases (answer validation, nested and
audited attribute files, version and cache, scratch, indexed reading,
native and legacy locations); every function in the file is at or under
the ceiling. No behaviour changes: the same commands, refusals, cache and
digest bytes (a plan's revision is identical before and after).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AbirAbbas
AbirAbbas force-pushed the fix/land-apple-git-attributes branch from de751f5 to 45b4b59 Compare November 2, 2026 15:45
@AbirAbbas
AbirAbbas marked this pull request as ready for review November 2, 2026 16:42
@AbirAbbas
AbirAbbas merged commit 84347ff into app/v3 Nov 2, 2026
12 of 20 checks passed
@AbirAbbas
AbirAbbas deleted the fix/land-apple-git-attributes branch November 2, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant