Treat a Non-Blob ls-tree Entry as Absent in _git_revisions - #1019
Conversation
git ls-tree only proved rel_path had *some* entry at a revision, not that the entry was a regular file: a file-to-directory transition (a canonical path later replaced by a directory of the same name) still returns a non-empty ls-tree line, so the code proceeded to git show, which succeeds on a tree path and returns a directory listing, not file content. That listing would then be hashed and compared as if it were the file's real text. Parse the ls-tree entry's type field and only treat rel_path as present when it is 'blob'. Anything else (a tree from a file-to-directory transition, a commit gitlink from a submodule) reads the same as absent. Added a self-test covering the file-to-directory transition. ## Validation - python3 spec/audit.py --selftest - uvx ruff check / uvx ruff format --check spec/audit.py - uvx mypy spec/audit.py - python3 scripts/prose_lint.py (full check set) - python3 scripts/repo_gate.py Raised by CodeRabbit on PR #1016 (develop -> main promotion).
PR Summary by QodoTreat non-blob Git revisions as absent file content
AI Description
Diagram
High-Level Assessment
Files changed (1) |
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthrough
ChangesGit revision path handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk:⚪ Minimal · up to This localized change makes non-file tree entries behave as absent during revision checks, preventing directory listings from being treated as file content; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code Review by Qodo
1. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
git ls-treeonly proved rel_path had some entry at a revision, not that the entry was a regular file: a file-to-directory transition (a canonical path later replaced by a directory of the same name) still returns a non-empty ls-tree line, so the code proceeded togit show, which succeeds on a tree path and returns a directory listing, not file content. That listing would then be hashed and compared as if it were the file's real text.Fix
Parse the ls-tree entry's type field and only treat rel_path as present when it is
blob. Anything else (a tree from a file-to-directory transition, a commit gitlink from a submodule) reads the same as absent. Added a self-test covering the file-to-directory transition.Validation
python3 spec/audit.py --selftestuvx ruff check/uvx ruff format --check spec/audit.pyuvx mypy spec/audit.pypython3 scripts/prose_lint.py(full check set)python3 scripts/repo_gate.pyRaised by CodeRabbit on PR #1016 (develop -> main promotion).
🤖 Generated with Claude Code
Summary by CodeRabbit