GitSavvy icon indicating copy to clipboard operation
GitSavvy copied to clipboard

Feature request: Support staging (add) multiple rows in inline diff

Open asfaltboy opened this issue 8 years ago • 11 comments

As can be done with git gui, I would like the ability to "visual select" a range of rows and hit L to stage all of these (but not the entire hunk they may possibly be in.

asfaltboy avatar Aug 23 '16 08:08 asfaltboy

That would be awesome, I had a few cases just this morning where the ability to stage select lines would have saved me some time.

ZaLiTHkA avatar Aug 25 '16 09:08 ZaLiTHkA

This will be super hard to add this functionality on top of what we have now. Not impossible, but hard, given the complexity of the code. But I've been considering other ways to abstract away some of the inline-diff complexity, and that may result in a partial rewrite. If that occurs, this is definitely something I'll be keeping in mind. And some intrepid contributor may decide to tackle it in the meantime :)

divmain avatar Dec 16 '16 09:12 divmain

Would it be easier to implement staging multiple contiguous selected lines? My guess is that that's often the use case, and if several lines from several different hunks needed to be staged, it's still a good amount of time saved.

If one had the have a cursor pr. line, I think that would be all right too, since it's easy to split a selection into cursors... and given that so many other plugin works with multiple cursors, I'd guess it's just some kind of loop over the cursors that's needed? :)

AllanLRH avatar May 31 '17 15:05 AllanLRH

Inline diff is messy.

Not saying I want. It will give me some headache. It is simpler to stage one select on several lines then each of those lines separately. If we want to allow multiple cursors we should start with the one farthest down in the file, because the we could generate the diff from the closest header.

These lines are the one responsible for staging lines.

stoivo avatar May 31 '17 21:05 stoivo

Could be awesome to be able stage a multiline selection at once !

CromFr avatar Jun 24 '18 14:06 CromFr

Why do you want to stage multiple selections on the inline diff? I think it makes more sense to stage one selection but all lines included in the selection.

PR is always welcome

stoivo avatar Jun 26 '18 19:06 stoivo

I meant to be able to stage all lines in a single selection at once, instead of pressing L many times, that often stage unwanted lines.

Something close to this workflow would really be handy: peek 2018-06-26 21-45

I'd love to open a PR myself, but I can barely understand python & don't know much about sublime API :/

CromFr avatar Jun 26 '18 19:06 CromFr

I remember trying to add support for multiline staging. It'll require a partial rewrite of the related codebase. Given that it'll only have a little bit of gain, I am not sure if someone (including myself) would invest time in this matter.

randy3k avatar Jun 26 '18 19:06 randy3k

By the way, this is the related code. Take a look if you are interested in contributing.

randy3k avatar Jun 26 '18 19:06 randy3k

@CromFr which editor is that? That looks slick!

For whoever is implementing this. You might want to take a look at git-gui's tcl source code; it's apply_range_or_line proc has a nice large comment about staging multiple lines. It's very similar to what we're doing with applying a patch to single lines, but they continue iterating over all lines in all diff-hunks, creating a large string consisting of the custom patches from selection.

asfaltboy avatar Jun 27 '18 05:06 asfaltboy

@asfaltboy This is gitg, I rely on it when I need to stage selectively many lines of a file

CromFr avatar Jun 27 '18 09:06 CromFr