Repository navigation
fix(modify): ignore untracked files - #3
windsornguyen wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6cdb5feb18
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| func (d *defaultOps) HasUncommittedChanges() (bool, error) { | ||
| out, err := run("status", "--porcelain") | ||
| out, err := run("status", "--porcelain", "--untracked-files=no") |
There was a problem hiding this comment.
Preserve untracked files before reset-based recovery
When modify is allowed to start with untracked files, a later apply failure or gh stack modify --abort runs modify.Unwind, which checks out snapshot branches and calls git.ResetHard (internal/modify/apply.go:996-1000). Git's reset --hard docs say it overwrites the working tree and “may overwrite untracked files” (https://git-scm.com/docs/git-reset), so an untracked path that is tracked on any stack branch can be silently replaced during recovery. Before this change the precondition blocked that state; please either continue rejecting conflicting untracked paths or stash/preserve them before reset-based unwind.
Useful? React with 👍 / 👎.
|
|
||
| func (d *defaultOps) HasUncommittedChanges() (bool, error) { | ||
| out, err := run("status", "--porcelain") | ||
| out, err := run("status", "--porcelain", "--untracked-files=no") |
There was a problem hiding this comment.
Avoid recording non-started rebases as conflicts
Allowing all untracked files through means git rebase --onto can fail before a rebase starts when an untracked path would be overwritten by checkout; Git documents that checkout refuses this case unless forced (https://git-scm.com/docs/git-checkout). ApplyPlan records any RebaseOnto error as PhaseConflict and saves the already-reordered stack metadata, but ContinueApply skips RebaseContinue when git.IsRebaseInProgress() is false and still prints success for that branch (internal/modify/apply.go:586-618, 847-852). In that scenario, removing the untracked file and running gh stack modify --continue leaves the branch unreplayed while the stack file says the new order/base is applied.
Useful? React with 👍 / 👎.
|
|
||
| func (d *defaultOps) HasUncommittedChanges() (bool, error) { | ||
| out, err := run("status", "--porcelain") | ||
| out, err := run("status", "--porcelain", "--untracked-files=no") |
There was a problem hiding this comment.
Don't treat pre-start cherry-picks as resumable
For fold-down, an untracked file can also make git cherry-pick fail before Git creates a cherry-pick state, for example when the folded commit adds the same path; the cherry-pick manual requires a clean working tree and --continue only continues an operation already in progress (https://git-scm.com/docs/git-cherry-pick). This code records every git.CherryPick error as ConflictType = "cherry_pick" (internal/modify/apply.go:402-421), so after the user moves the untracked file, gh stack modify --continue just runs git cherry-pick --continue and fails with no operation in progress instead of applying the folded commits.
Useful? React with 👍 / 👎.
Reproduction
modifyexits with "uncommitted changes in working tree" even though the file is untracked.Fixes github#111.
Change
Checks tracked changes only. Modified or staged tracked files still block
modify.Proof
go vet ./...go test -race -count=1 ./...