How to reset selected lines?
- From
Pratyush Yadav <me@yadavpratyush.com>
- Date
- Aug 13, 2019, 14:18 UTC
- Message-ID
- <20190813141816.yoer6pfjdnlgtj76@localhost.localdomain>
Hi,
To put things into context of why I am asking this, git-gui has a feature where you can select parts of a displayed diff, and can stage/unstage those parts. That feature is implemented in git-gui by just generating a diff from the selected lines, and then applying it. Check git-gui/lib/diff.tcl:643 for the implementation.
Now, I want to add a similar feature, but one that discards/resets the selected lines. And I'd like to avoid the hack that git-gui's apply_range_or_line is. So, is there a cleaner way to do this that does not involve generating a diff and then applying it?
Also, if there is a better way of staging and unstaging selected lines as well, do let me know, and I will try to fix git-gui's hacky way of doing it.
-- Regards, Pratyush Yadav