Skip to content

[codex] fix stash pop index preservation#429

Merged
genedna merged 4 commits into
mainfrom
codex/fix-stash-pop-index
Jul 6, 2026
Merged

[codex] fix stash pop index preservation#429
genedna merged 4 commits into
mainfrom
codex/fix-stash-pop-index

Conversation

@genedna

@genedna genedna commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve the current index during default libra stash apply / pop, so restored tracked changes come back as unstaged working-tree edits.
  • Add regression coverage for unstaged-only, staged-only, and mixed tracked-file stash pop cases.
  • Update stash, merge-autostash, and compatibility docs to document the default index behavior and deferred --index mode.

Root Cause

apply_stash_commit restored the merged stash tree into the working tree and then rebuilt the index from that same tree. That staged restored stash content by default, diverging from Git default stash apply / pop behavior and making a later libra commit include the restored change before the user ran libra add.

Validation

  • LIBRA_SKIP_WEB_BUILD=1 cargo test --test command_test stash_pop_restores_ -- --nocapture
  • LIBRA_SKIP_WEB_BUILD=1 cargo test --test command_test stash_test -- --nocapture
  • LIBRA_SKIP_WEB_BUILD=1 cargo test --test command_test merge_autostash -- --nocapture
  • cargo +nightly fmt --all --check
  • Manual CLI reproduction confirmed stash pop now leaves status --short as M tracked.txt.

genedna and others added 3 commits July 6, 2026 11:46
Signed-off-by: Eli Ma <eli@patch.sh>
Signed-off-by: Eli Ma <eli@patch.sh>
Copilot AI review requested due to automatic review settings July 6, 2026 05:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes libra stash apply / pop to preserve the current index by default so restored tracked changes come back as unstaged working-tree edits (matching Git’s default behavior), and updates tests/docs to lock in the contract.

Changes:

  • Stop rebuilding/saving the index from the merged stash tree during apply_stash_commit (worktree-only restore by default).
  • Add regression tests covering unstaged-only, staged-only, and mixed tracked-file stash pop cases.
  • Update stash/merge-autostash/compatibility documentation to describe the default index behavior and the deferred --index mode (plus a pnpm version bump for web/).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web/package.json Updates the pinned pnpm package manager version for the web workspace.
tests/command/stash_test.rs Adds status --short helper + new regression tests for default stash pop index behavior.
src/command/stash.rs Changes stash apply/pop implementation to stop rebuilding the index and preserve it by default.
docs/development/tracing/sandbox.md Adds comparative notes about ricccrd/dd to the macOS sandbox research baseline/analysis.
docs/development/commands/stash.md Documents default worktree-only restore behavior and deferred --index.
docs/development/commands/merge.md Updates merge autostash documentation to reflect the new default stash restore semantics.
docs/commands/stash.md Updates user-facing stash docs to explain default worktree-only restore (unstaged results).
COMPATIBILITY.md Updates the stash row to document default index preservation on apply/pop.

Comment thread docs/development/commands/merge.md Outdated
Comment thread src/command/stash.rs
Signed-off-by: Eli Ma <eli@patch.sh>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@genedna genedna marked this pull request as ready for review July 6, 2026 05:56
@genedna genedna merged commit eecf018 into main Jul 6, 2026
9 of 11 checks passed
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.

2 participants