Skip to main content
deleted 38 characters in body
Source Link

There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region (mark a region, hit stage), or to shrink/grow all hunks using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations:

  • baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it.

  • bar and baz being only partially related, meaning that their changes should not be in the same commit.

  • bar is large and baz is small, making it a lot easier to split the hunk rather than select bar

  • Similar to the last point, say a 20 line commit contains a single line the middle that should not be staged. It'd be easier to split & stage the top and bottom two hunks ignoring the middle one than use the region.

  • The above can arise sometimes when the diff presentation will separate the before and after of something that's been modified, and have something unhelpful in the middle. e.g.

@ looks like the markdown parser's broken here

 
@@ line
- old_foo
+ random stuff
+ new foo

There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region (mark a region, hit stage), or to shrink/grow all hunks using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations:

  • baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it.

  • bar and baz being only partially related, meaning that their changes should not be in the same commit.

  • bar is large and baz is small, making it a lot easier to split the hunk rather than select bar

  • Similar to the last point, say a 20 line commit contains a single line the middle that should not be staged. It'd be easier to split & stage the top and bottom two hunks ignoring the middle one than use the region.

  • The above can arise sometimes when the diff presentation will separate the before and after of something that's been modified, and have something unhelpful in the middle. e.g.

@ looks like the markdown parser's broken here

@@ line
- old_foo
+ random stuff
+ new foo

There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region (mark a region, hit stage), or to shrink/grow all hunks using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations:

  • baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it.

  • bar and baz being only partially related, meaning that their changes should not be in the same commit.

  • bar is large and baz is small, making it a lot easier to split the hunk rather than select bar

  • Similar to the last point, say a 20 line commit contains a single line the middle that should not be staged. It'd be easier to split & stage the top and bottom two hunks ignoring the middle one than use the region.

  • The above can arise sometimes when the diff presentation will separate the before and after of something that's been modified, and have something unhelpful in the middle. e.g.

 
@@ line
- old_foo
+ random stuff
+ new foo
Added some motivation examples to want to split hunks rather than use the region.
Source Link
Squidly
  • 1.5k
  • 14
  • 19

There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region (mark a region, hit stage), or to shrink/grow all hunks using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations include baz being a debug statement, so I'd:

  • baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it.

  • bar and baz being only partially related, meaning that their changes should not be in the same commit.

  • bar is large and baz is small, making it a lot easier to split the hunk rather than select bar

  • Similar to the last point, say a 20 line commit contains a single line the middle that should not be staged. It'd be easier to split & stage the top and bottom two hunks ignoring the middle one than use the region.

  • The above can arise sometimes when the diff presentation will separate the before and after of something that's been modified, and have something unhelpful in the middle. e.g.

@ looks like to drop it from the commit of foo & bar without getting rid of it. Or just bar and baz being only partially related, meaning that their changes should not be in the same commit.markdown parser's broken here

@@ line
- old_foo
+ random stuff
+ new foo

There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region (mark a region, hit stage), or to shrink/grow all hunks using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations include baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it. Or just bar and baz being only partially related, meaning that their changes should not be in the same commit.

There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region (mark a region, hit stage), or to shrink/grow all hunks using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations:

  • baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it.

  • bar and baz being only partially related, meaning that their changes should not be in the same commit.

  • bar is large and baz is small, making it a lot easier to split the hunk rather than select bar

  • Similar to the last point, say a 20 line commit contains a single line the middle that should not be staged. It'd be easier to split & stage the top and bottom two hunks ignoring the middle one than use the region.

  • The above can arise sometimes when the diff presentation will separate the before and after of something that's been modified, and have something unhelpful in the middle. e.g.

@ looks like the markdown parser's broken here

@@ line
- old_foo
+ random stuff
+ new foo
added 14 characters in body
Source Link
Squidly
  • 1.5k
  • 14
  • 19

There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region using C-SPC(mark a region, hit stage), or to shrink/grow the hunkall hunks using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations include baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it. Or just bar and baz being only partially related, meaning that their changes should not be in the same commit.

There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region using C-SPC, or to shrink/grow the hunk using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations include baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it. Or just bar and baz being only partially related, meaning that their changes should not be in the same commit.

There's a question on SO about splitting hunks using magit, and the two solutions given are to either stage the region (mark a region, hit stage), or to shrink/grow all hunks using + & -. That's not what I'm after.

In magit's status buffer, I want to split a hunk into two hunks, at the point, or at least at the lines around the point.

Turning this (excuse my bad diff formatting)

@@ blah blah blah
- foo
+ bar
+ baz
+

Into

@@ blah blah
- foo
+ bar

@ blah blah
+ baz

When the point is on bar.

Motivations include baz being a debug statement, so I'd like to drop it from the commit of foo & bar without getting rid of it. Or just bar and baz being only partially related, meaning that their changes should not be in the same commit.

added 253 characters in body
Source Link
Squidly
  • 1.5k
  • 14
  • 19
Loading
Source Link
Squidly
  • 1.5k
  • 14
  • 19
Loading