Skip to content

fix(ce-commit-push-pr): preserve ignored files during branch switches - #1647

Merged
tmchow merged 2 commits into
EveryInc:mainfrom
22nsuk:fix/preserve-ignored-worktree-upstream
Sep 10, 2026
Merged

fix(ce-commit-push-pr): preserve ignored files during branch switches#1647
tmchow merged 2 commits into
EveryInc:mainfrom
22nsuk:fix/preserve-ignored-worktree-upstream

Conversation

@22nsuk

@22nsuk 22nsuk commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #1646.

git checkout -b silently overwrites ignored local files (e.g. .env) when the target commit tracks that path. git stash push -u does not save ignored files, so the documented retry still loses them. The upstack recipe git checkout -b -- "<name>" "<tip>" is also invalid (-- becomes the branch name).

Change

  • Use git checkout --no-overwrite-ignore -b … on the ordinary and upstack recipes.
  • On collision, stop and ask (pipeline: report). Do not stash.
  • Non-colliding dirty work still follows the new branch.
  • Real-Git tests execute the shipped recipes.

Dropped the extra worktree-safety.md layer and the “establish that gh stack preserves local paths” probe.

Validation

bun test tests/commit-push-pr-worktree-safety.test.ts tests/commit-push-pr-contract.test.ts — 32 pass, including ignored .env overwrite stop, non-colliding dirty work, and no-stash collisions.

Security Disclosure

Prevents silent overwrite of ignored local files during an authorized branch switch. Residual: gh stack classify / other tree-changing stack CLI calls are not covered by this flag; collision handling there is unchanged.

Agent Disclosure

  • Model: Cursor Grok 4.6 (slim of the original change). Original recipes/tests: Codex / ChatGPT as disclosed on the first commit.

Abort direct tree-changing checkouts on ignored-path collisions instead
of silently overwriting local files or retrying through stash -u. Apply
one shared preservation condition to ordinary and stack workflows,
including topology changes, without requiring a clean worktree.

Correct the upstack checkout argument order while retaining the
authoritative parent tip. Add isolated real-Git regression tests and
keep the existing stack contract aligned with the protected recipe.

Port the five reviewed fix/test blobs from fork PR #5 unchanged onto
upstream 098ccdb. The resulting tree is
identical to the integrated fork validation commit 49f9e7a.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-07T08:20:14.833838Z e4cd635 PR opened
🔒 Security Review Completed 2026-09-07T08:21:57.339746Z e4cd635 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Retain --no-overwrite-ignore and stop-on-collision on the two branch
recipes. Remove the extra reference and the unverifiable gh-stack probe.

Co-authored-by: Trevin Chow <tmchow@users.noreply.github.com>
@cursor

cursor Bot commented Sep 7, 2026

Copy link
Copy Markdown

Slimmed this on the branch.

Kept --no-overwrite-ignore and stop-on-collision on the two checkout recipes (the ignored-file overwrite and the broken git checkout -b -- ordering are real). Removed worktree-safety.md and the “establish that gh stack preserves local paths” probe — that isn’t something an agent can verify without mutating.

Real-Git tests that execute the shipped recipes still pass.

@tmchow
tmchow merged commit 6a00e35 into EveryInc:main Sep 10, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 10, 2026
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.

ce-commit-push-pr can overwrite ignored local files when switching to a fresh base

3 participants