fix(git): handle submodule gitlinks and directory symlinks in working-copy snapshots
Cherry-picked from my fork's megamerge branch. Fix panics in working-copy snapshot/amend paths when changed entries are not regular files. Previously, snapshot/amend attempted to create blobs by reading paths from disk unconditionally. That fails for: - submodule gitlinks (mode 160000), where path is a directory in superproject - directory symlinks like `ln -s dir/ link`, where symlink handling must use link target bytes, not file read semantics Changes: - add mode-aware object creation for working-copy paths - regular blobs: read file bytes - symlinks: read symlink target and store as blob content - gitlinks/submodules: use index OID instead of reading filesystem path - unreadable/tree: skip as absent - wire mode-aware logic into: - snapshot unstaged commit creation - amend_fast working-copy path processing - add regressions: - dirty submodule no longer crashes status/snapshot flow - trailing-slash directory symlink no longer crashes snapshot flow - amend with dirty submodule no longer crashes - make tests use per-repo submodule source paths to avoid cross-test collisions Fixes https://github.com/arxanas/git-branchless/issues/517 Fixes https://github.com/arxanas/git-branchless/issues/645 Co-authored-by: pi with GPT-5.3-Codex <pi-gpt-5.3-codex@codex.local>
B
bitbloxhub committed
5b2ac72d005563b323bb82d205fdba613aa0ace4
Parent: ff30de8
Committed by claytonrcarter <claytonrcarter@gmail.com>
on 5/20/2026, 1:52:23 AM