Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Allow to stage hunks and lines #27

Open
demian85 opened this issue May 15, 2014 · 12 comments
Open

Allow to stage hunks and lines #27

demian85 opened this issue May 15, 2014 · 12 comments

Comments

@demian85
Copy link

I see that someone have recently implemented the .add method to stage files into the index.
For months I've been looking for a way to programatically stage hunks and lines from a file, the same way native git-gui app does it.
By any chance, is it more or less easy to implement that functionality into git-utils?
My project (https://github.com/demian85/git-watcher) has been in stand by since I noticed almost everyone in my office need that functionality in order to at least try my app!

Thanks for your help.

@demian85
Copy link
Author

demian85 commented Jun 5, 2014

I found someone that is willing to help with the implementation of libgit2 methods related to file patching.
Apart from me, is anyone interested in the addition of this kind of functionality to this library?
A nice addition would be a method like add(<file>, <line>).

Can anyone provide me with a hint about which libgit2 functions are needed?

Thanks!

@demian85
Copy link
Author

Just an update. I found a way to do this without using libgit.
Actually, you can just make a patch with git diff, edit and remove the parts you do not want and then git apply --cached

It still would be useful to have line staging, since that is really hard to implement and hackis. You need to remove lines and edit hunk headers manually with a magic regexp....

@matterweave
Copy link

This issue looks quite old at this point, but I've noticed support has still not been added for something like this. I'd be interested in researching and augmenting git-utils with non-hacky methods for staging and unstaging lines if there's both a desire for it and an expectation that it would be included at some point. I may proof it out soon anyway just to see how feasible it is.

It'd certainly be handy for an Atom package I'm working on that provides a UI-centric version of the same functionality.

@danShumway
Copy link

Would really appreciate having something like this as well.

@nikki-pru
Copy link

+1

@geddski
Copy link

geddski commented Apr 15, 2016

was looking for this very thing in Atom, would be nice.

@brandoncc
Copy link

+1

5 similar comments
@ehaselwanter
Copy link

+1

@brabster
Copy link

+1

@samvk
Copy link

samvk commented May 17, 2017

+1

@andrei-a-papou
Copy link

+1

@dguera
Copy link

dguera commented Feb 15, 2018

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests