Fix gitattributes filter snapshot edge cases - #9676
Conversation
There was a problem hiding this comment.
The following commits do not follow our format for subject lines:
- 311503a: Fix gitattributes snapshot review issues
Commits should have a subject line following the format <topic>: <description>. Please review the commit guidelines for more information.
311503a to
fe54182
Compare
All commits are now correctly formatted. Thank you for your contribution!
fe54182 to
65fd11f
Compare
|
Reminder to fill out the PR template. I'm mentioning this especially because the PR description sounds quite LLM-generated. |
This is a long list. Would it make sense to create one commit per item (roughly)? |
10a1b7b to
fa94c4e
Compare
Add regression tests for snapshot paths where filter-matched files are handled incorrectly. The expectations document pre-fix behavior, so this commit passes before the implementation changes.
Create gitattributes lookup state from the tree being snapshotted, not from the empty initial tree. Also apply filter ignores while scanning tracked files through ignored-directory shortcuts, so snapshot preserves filtered tree contents consistently.
Document that filter matching currently treats a failed .gitattributes load as a non-match. That lets snapshot continue with content that may have been protected by a configured filter, so the next commit changes this to a visible error.
fa94c4e to
b087429
Compare
Return an error from filter matching when .gitattributes cannot load. Snapshot should fail instead of treating unreadable attributes as non-matches and recording filtered content. Still ignore optional attribute probes when an ancestor path is a file. Those NotADirectory lookups mean no .gitattributes file exists there, not that attribute loading failed.
Document that jj run snapshots its temporary working copy without the configured gitattributes filter ignores. The test records the pre-fix rewrite so the next commit can change only implementation and expected result.
Use configured git.ignore-filters when jj run snapshots its temporary working copies. Without this, commands can rewrite tracked files even though normal snapshots would leave them untouched.
Document that external diffedit currently snapshots its temporary output working copy without configured gitattributes filter ignores. The test records the pre-fix edited output before the implementation is fixed.
Use git.ignore-filters for external diffedit output snapshots. Otherwise an editor can rewrite tracked files even though normal snapshots would preserve tree contents.
Add regression coverage for the deletion snapshot path. The original PR already preserves tracked filter-matched files when they disappear from disk; this keeps that separate path covered alongside the update paths fixed earlier in the stack.
Carry the reviewed gix-attributes version and update the lockfile. This keeps dependency churn easy to review apart from behavior changes.
Move print_error_sources into the git-only transaction path so no-git builds do not keep an unused import. This is build hygiene exposed while validating the temporary snapshot fixes with --no-default-features.
Document that git.ignore-filters applies only while jj snapshots local working-copy contents. Imports from Git commits still preserve committed tree contents, so the setting is not part of Git import semantics. Keep the schema docs aligned with the new configuration key.
Collect the shared jj run worker inputs in a small context struct so the producer entry point stays under clippy's argument-count limit.
b087429 to
b5d9f45
Compare
|
I did a deeper validation pass to make the review easier. The issues in this stack are real code-path problems, not just theoretical edge cases, and the tests are meant to document the failure modes separately.
I re-ran the targeted validation locally:
|
sbarfurth
left a comment
There was a problem hiding this comment.
I tried this and it (still) works well. In terms of Rust code quality I can't promise the best review, but to my eye it looks perfectly fine. LGTM.
There was a problem hiding this comment.
imo, this belongs into @kejadlen/@sbarfurth's PR adding the feature
There was a problem hiding this comment.
I think the goal of this PR is to merge into mine (or the one from @kejadlen), right? At least that was my understanding.
There was a problem hiding this comment.
yes - this is an intentionally stacked PR on that. The intent here was to review, but rather than just give vague fix this problem reviews coming from codex, this more properly tests that the problems listed are problems and then fixes them
|
@sbarfurth I've rebased and merged these into your PR. |
This splits the follow-up to #9635 into focused review commits. The first commits characterize the wrong behavior found during review, and the following commits update those same tests while fixing the corresponding path.
Review guide:
test: characterize filtered snapshot paths/git-lfs: fix filtered snapshot pathscover stale.gitattributesfallback and tracked files under ignored directories.test: characterize gitattributes lookup errors/git-lfs: propagate gitattributes lookup errorscover parse and read errors from attributes lookup. The fix commit also keeps optional.gitattributesprobes from failing when an ancestor path is a file, with a separate regression test for theNotADirectorycase found after CI exercised rename detection.test: characterize run temp snapshot filters/git-lfs: pass ignore filters to run snapshotscover temporary snapshots created byjj run.test: characterize diffedit temp snapshot filters/git-lfs: pass ignore filters to diffedit snapshotscover temporary snapshots created by diff editing.gix-attributes, keep no-default-features builds clean, document the snapshot-only behavior, and groupjj runworker inputs in a small context struct so clippy's argument-count lint stays green.The rebuilt stack was compared against the previous flat version of this PR. The intentionally new follow-up delta is limited to the
NotADirectory.gitattributesregression fix/test and theRunContextclippy cleanup.Validation run locally:
cargo test -p jj-lib test_disk_file_loader_ignores_file_in_attributes_path -- --nocapturecargo test -p jj-cli test_diff_renamed_file_and_dir -- --nocapturecargo clippy -p jj-cli --all-targets --all-features -- -D warningscargo +nightly fmt --all -- --checkChecklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)