Sublime Forum

What is the normal way to skip indivdual hunks?

#1

I’ve just installed merge. The UI is nice. But I’m not finding an easy way to skip hunks when committing hunk by hunk. How do you stage just a few hunks?

For example, I’ve selected a modified file’s tab and see buttons for “Nothing to commit”, “Discard”, and “Stage”. The full file is displayed. If I move the mouse into the text body, the last two buttons change to “Discard Hunk” and “Stage Hunk”. If I hit “Stage Hunk”, and the file wasn’t in the first tab, I’m unexpectedly taken back to the first tab. When I return to the tab for the file with the hunks I want to commit, it shows a view with just the hunks – but all of them are staged. So, it seems, I then need to individually unstage the hunks I don’t want in that commit.

If I only want to commit a few hunks from the file, that approach seems awkward. What am I not seeing?

0 Likes

#2

Hi @ravens.eye,

Thanks for reaching out!

Each hunk should have its own stage hunk / discard_hunk buttons associated with it, which is visible when the cursor is moved into the hunk (or the hunk is selected). This is in addition to the stage and discard buttons which will still operate on the entire file.

Sublime Merge will return to the first modified file if the currently selected file is staged and no more changed hunks are left. It may be the case that all the changes are grouped into a single hunk. If this is the case, then pressing stage hunk would stage the entire file. Could you confirm if this is the case?

Kind regards,
- Dylan from Sublime HQ

0 Likes

#3

Thank you for the quick response!

The staging process for hunks you described is very much what I would expect. I have no clue why I’m not seeing that behavior.

The file diffs are well separated, a few lines each scattered throughout the file.

I never see individual Stage Hunk / Discard Hunk buttons for those hunks. But I do get Discard Lines / Stage Lines buttons if I click on a line in a hunk. Discard Hunk / Stage Hunk buttons appear when I move the mouse cursor into the body of the file but do not seem to be associated with a particular hunk. Hovering the mouse cursor over a hunk has no additional effect – I don’t seem to be able to select a single hunk when the full file is being displayed (but I can drag the cursor over lines inside a hunk and select them)

When I hit Stage Hunk all hunks are staged at once and the file is moved to the “Staged Files” area. So, from your explanation I now understand why it then selected the first “Modified Files” tab after doing that.

Well, I’ll be. Never mind. While the hunk buttons are displayed, an “arrow” icon appears on the far left side of their bar. Clicking on that icon toggles between showing only modified hunks or showing the entire file – the default seems to be showing the entire file. After clicking on that icon, I get the exact behavior you described! (BtW, that icon is kind of tiny :wink: )

You’ve built a great tool! I’m looking forward to using it.

BtW, I’m running it under Linux Mint:

Distributor ID:linuxmint
Description:Linux Mint 21.1
Release:21.1
Codename:vera

And using Sublime Merge Build 2083

0 Likes