Skip to content

fix(modify): ignore untracked files - #3

Open
windsornguyen wants to merge 1 commit into
mainfrom
codex/ignore-untracked-modify
Open

windsornguyen wants to merge 1 commit into
mainfrom
codex/ignore-untracked-modify

Conversation

@windsornguyen

@windsornguyen windsornguyen commented Jul 12, 2026 •

Copy link
Copy Markdown
Owner

Reproduction

touch untracked.txt
gh stack modify

modify exits 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

  • Real Git test covers both an untracked file and a modified tracked file
  • go vet ./...
  • go test -race -count=1 ./...

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread internal/git/gitops.go

func (d *defaultOps) HasUncommittedChanges() (bool, error) {
out, err := run("status", "--porcelain")
out, err := run("status", "--porcelain", "--untracked-files=no")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread internal/git/gitops.go

func (d *defaultOps) HasUncommittedChanges() (bool, error) {
out, err := run("status", "--porcelain")
out, err := run("status", "--porcelain", "--untracked-files=no")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread internal/git/gitops.go

func (d *defaultOps) HasUncommittedChanges() (bool, error) {
out, err := run("status", "--porcelain")
out, err := run("status", "--porcelain", "--untracked-files=no")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

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.

gh stack modify fails with untracked files

1 participant