Skip to content

feat(git): add hunk revert - #31

Merged
WarheadTaylor merged 2 commits into
masterfrom
t3code/add-discard-hunks
Sep 8, 2026
Merged

WarheadTaylor merged 2 commits into
masterfrom
t3code/add-discard-hunks

Conversation

@WarheadTaylor

Copy link
Copy Markdown
Member

Summary

  • Add Git support for discarding individual unstaged hunks.
  • Expose the discard operation through IPC and the preload API.
  • Add confirmation UI and preserve other hunks and staged changes.
  • Add renderer and integration coverage for modified, deleted, and untracked files.

Testing

  • Added App history test for confirmation, cancellation, discard, and diff reload behavior.
  • Added integration tests covering partial hunk discard, stale patches, invalid sides, deleted files, and untracked files.

- Add IPC and Git service support for reversing unstaged hunks
- Add confirmation UI and coverage for preserving staged and other changes
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 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-08T19:11:26.892651Z d36f3b8 New commits
ℹ️ 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.

@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: e43561b1e8

ℹ️ 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 src/main/gitService.ts
Comment on lines +1025 to +1029
return this.runGitOperation(request.repoPath, [
"apply",
"--reverse",
"--whitespace=nowarn",
"-"

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 file-mode edits when discarding a content hunk

When a file has both an unstaged mode change (such as chmod +x) and content edits, the selected hunk patch still contains the file-level old mode/new mode headers collected by groupDiffRowsByHunk. Passing that patch directly to git apply --reverse therefore reverts the executable-bit change along with the selected content hunk, silently discarding an unrelated working-tree edit. Remove file-mode metadata from the patch used for this operation so that only the chosen hunk is reversed.

Useful? React with 👍 / 👎.

- Update hunk action labels, progress text, dialogs, and errors
- Adjust history tests for the revised terminology
@WarheadTaylor WarheadTaylor changed the title Add unstaged hunk discard feat(git): add hunk revert Sep 8, 2026
@WarheadTaylor
WarheadTaylor merged commit d2bfe46 into master Sep 8, 2026
3 of 4 checks passed
@WarheadTaylor
WarheadTaylor deleted the t3code/add-discard-hunks branch September 8, 2026 19:05

@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: d36f3b8d8f

ℹ️ 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 src/renderer/App.tsx
disabled: disabled || diffChanged,
onApply: onApplyHunk
onApply: onApplyHunk,
onDiscard: selectedSide === "unstaged" ? (patch) => onApplyHunk(patch, true) : undefined

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid offering hunk reversion for submodule gitlinks

When an initialized submodule is checked out at a different commit, its unstaged diff is a text hunk and this unconditionally exposes Revert Hunk. I checked git apply -h (--reverse: “apply the patch in reverse”) and reproduced the resulting 160000 gitlink patch behavior: git apply --reverse exits 0 with an unable to rmdir warning while leaving the submodule HEAD unchanged, so discardHunk reports success and the same change reappears after refresh. Gate this action when selectedFile?.submodule is present, or implement submodule checkout semantics instead of applying the gitlink patch.

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.

1 participant