Skip to content

fix(git): handle submodule gitlinks and directory symlinks in working-copy snapshots#1659

Open
bitbloxhub wants to merge 1 commit intoarxanas:masterfrom
bitbloxhub:cherrypick-fix/snapshot-submodule-symlink
Open

fix(git): handle submodule gitlinks and directory symlinks in working-copy snapshots#1659
bitbloxhub wants to merge 1 commit intoarxanas:masterfrom
bitbloxhub:cherrypick-fix/snapshot-submodule-symlink

Conversation

@bitbloxhub
Copy link
Copy Markdown
Contributor

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 #517
Fixes #645

…-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 arxanas#517
Fixes arxanas#645

Co-authored-by: pi with GPT-5.3-Codex <pi-gpt-5.3-codex@codex.local>
@bitbloxhub bitbloxhub force-pushed the cherrypick-fix/snapshot-submodule-symlink branch from b6409e8 to 7a0651a Compare April 24, 2026 16:41
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.

Creating working copy snapshot panics with directory symlink ending in '/' Snapshotting not implemented for submodules

1 participant