feat: add commit_files for multi-path commits and fix repo-relative path resolution for nested config dirs - #679
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
commit_files for multi-path commits and fix repo-relative path resolution for nested config dirs
🎨 Storybook previewUpdated for 69e2e8d
|
darkmatteragent
left a comment
There was a problem hiding this comment.
Review — APPROVE
69e2e8d2c82f · 0 findings
Approve: solid hardening — every producer/consumer boundary checks out. - All app callers pass the git toplevel plus repo-relative filenames, which repo_relative_path reproduces unchanged; the nested-config-dir case is fixed as intended. - Per-hunk commit/discard keeps hunk granularity through find_hunk_by_hash; no sibling-row mutation exists. - Escape/symlink paths fail closed before mutation, and the index.write() reorder preserves intent-to-add entries, with new tests locking both in.
No findings.
|
No findings. reviewed: 69e2e8d — 2026-09-04T07:53Z verdict: approve findings: 0
Run details
|
📋 PR Overview
🔬 Coverage
|
| @@ -425,8 +482,7 @@ pub fn restore_hunk(dir: &str, path: &str, hunk: &str) -> Result<()> { | |||
| /// as an empty blob instead. | |||
| pub fn commit_hunk(dir: &str, path: &str, hunk: &str, message: &str) -> Result<CommitInfo> { | |||
There was a problem hiding this comment.
Severity 2 — not blocking
commit_hunk still has the write-before-bail shape this PR fixes in commit_files: further down (line 550) the index is written before the nothing to commit check. It's practically unreachable today (find_hunk_by_hash just found the hunk in the live diff), but the lookup→commit window is a check-then-act race, and when the bail does fire it clobbers intent-to-add entries the same way. Same two-line move as in commit_files?
| @@ -318,8 +376,7 @@ fn index_entry_differs_from_head( | |||
| /// drift row alive. Purely unstaged drift leaves the index untouched. | |||
| pub fn restore_hunk(dir: &str, path: &str, hunk: &str) -> Result<()> { | |||
There was a problem hiding this comment.
Severity 2 — not blocking
Now that paths here are dir-relative, restore_hunk/commit_hunk are only correct with dir = repo root: find_hunk_by_hash and file_diff_contents still match workdir-relative names, so a future caller passing a nested config dir would look a hunk up under one convention and resolve the file under the other. Worth a one-line comment on these two functions ("callers must pass the repo root until the query side is dir-relative too") so the first nested-dir caller finds out at review time instead of at runtime?
Juanpe Bolívar (arximboldi)
left a comment
There was a problem hiding this comment.
Oh damn! I guess I missed #655 (comment) before writing my review comment in #655 ... I think this probably solves my issues! Looking forward to re-try once this is in :)






Summary
This is to improve/harden the git layer to make it easier and less bug-prone supporting nested config dirs, based on this comment from Alex Shabalin (@alex-sparus) here: #655 (comment)
It also proactively adds the
commit_filesfunction which was in the PR that inspired said comment.The main thing to look at is the
repo_relative_pathmethod -- the correctness of its logic as well as its call sites.Test Plan
New unit tests.
Docs