Skip to content

Conversation

@mattzcarey
Copy link
Owner

Summary

  • Add git edit command for jj-style mid-stack editing
  • Enable traveling back to any ancestor commit, making changes, and auto-rebasing descendants
  • Implement edit state management using git refs for crash recovery
  • Add guardrail to block push during edit sessions
  • Include comprehensive tests for git edit feature

Commands

Command Description
`git edit ` Travel to commit for editing (detaches HEAD)
`git edit --back` Return to branch and rebase descendants
`git edit --continue` Continue after resolving a conflict
`git edit --abort` Cancel edit and restore original state
`git edit --status` Show current edit session state

Test plan

  • Build passes: `zig build`
  • Unit tests pass: `zig build test`
  • Integration tests: `cd test && bun run test`

Generated with Claude Code

Uses libgit2's git_revwalk to collect commits between a target
and HEAD (exclusive of target, inclusive of HEAD) in oldest-first
order. This is needed to identify which commits must be rebased
after editing a commit mid-stack.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Test coverage includes:
- Happy path: edit, amend, --back rebases descendants
- --abort: restores original state cleanly
- --status: reports accurately with active/inactive states
- Error on dirty tree: both for starting edit and --back
- Error on invalid target: non-existent commits, non-ancestors
- Error when edit already active
- Error from detached HEAD
- Conflict handling tests (skipped due to segfault bug in implementation)

The conflict handling tests document expected behavior but are skipped
because the current implementation has a bug in completeEdit() where
git_index_read_tree() is called with null, causing a segfault.
Resolve conflicts:
- AGENTS.md: Keep both git edit and agent subcommands sections
- src/passthrough.zig: Include all imports (edit, git, detect)
Bug fix:
- Replace git_index_read_tree(repo_index, null) with git_index_clear(repo_index)
- The null pointer caused a segfault when cherry-pick had conflicts

Test changes:
- Enable all 5 previously skipped conflict handling tests
- All 28 tests now pass with 0 skipped
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