atom / git-utils

Git Node Module
http://atom.github.io/git-utils
MIT License
166 stars 61 forks source link

Allow to stage hunks and lines #27

Open demian85 opened 10 years ago

demian85 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 9 years ago

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 commented 9 years ago

Would really appreciate having something like this as well.

nikki-pru commented 8 years ago

+1

geddski commented 8 years ago

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

brandoncc commented 8 years ago

+1

ehaselwanter commented 7 years ago

+1

brabster commented 7 years ago

+1

samvk commented 7 years ago

+1

andrei-a-papou commented 6 years ago

+1

dguera commented 6 years ago

+1