Skip to content

create-pr: synthetic commit approach could leave stranded commit on process crash #192

@jamesadevine

Description

@jamesadevine

Problem

The generate_patch() function in src/mcp.rs creates a synthetic commit (git add -A + git commit), runs git format-patch, then resets it (git reset HEAD~1). If the process is killed (OOM, SIGKILL) between commit and reset, the synthetic commit persists in the agent's working directory (not a worktree), potentially confusing subsequent agent invocations.

Suggested Fix

Consider a lighter alternative that avoids committing:

  • Use git stash --include-untracked before the merge-base diff, then git stash pop
  • Or pass --cached + unstaged diffs separately to avoid modifying git history

Context

The current implementation handles soft errors correctly (the reset runs before propagating format-patch errors, and the SHA is included in error messages). This issue is specifically about hard process kills that bypass cleanup. Low probability but worth a FIXME note if the synthetic-commit approach stays.

Identified in PR #155 review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions