Skip to content

feat: Allow for patch stage/unstage in Git diff viewer#585

Open
atreat wants to merge 16 commits intoDimillian:mainfrom
atreat:git-stage-patch
Open

feat: Allow for patch stage/unstage in Git diff viewer#585
atreat wants to merge 16 commits intoDimillian:mainfrom
atreat:git-stage-patch

Conversation

@atreat
Copy link

@atreat atreat commented Mar 26, 2026

Changes

  • Allows user to hover over hunks in git diff viewer and stage each individually.
  • Renders action button in gutter next to line numbers.
  • Will draw a vertical line on the left side of the hunk to highlight which changes are staged.
  • When hunk contains only a deletion, will render action button on right side of deletion hunk

Idea is to keep action buttons near the center of the scrollable region so see can skim through changes and quickly stage/unstage hunks.

Screenshots:

stage hunk:
stage-btn

unstage hunk:
unstage-btn

unstage deletion only:
unstage-deletion-btn

Copy link

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

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: dfee6d8a7e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1275 to +1278
let (diff_args, reverse_apply): (&[&str], bool) = match source {
"unstaged" => (&["diff", "--no-color", "-U0", "--"], false),
"staged" => (&["diff", "--cached", "--no-color", "-U0", "--"], true),
_ => unreachable!(),

Choose a reason for hiding this comment

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

P1 Badge Use ignore-whitespace mode when resolving display hunk IDs

When git_diff_ignore_whitespace_changes is enabled, get_git_diffs_inner computes displayHunkId values from git diff -w -U0 hunks, but this branch rebuilds the source patch without -w. In hunks that mix whitespace-only edits with real edits, the hunk header tuple (old_start/old_count/new_start/new_count) can differ, so build_display_hunk_patch cannot find the ID and returns “Display hunk no longer matches…”, breaking hunk stage/unstage in that mode.

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