Re: Staging commits with visual diff tools?
- From
Jeff King <peff@peff.net>
- Date
- May 27, 2015, 07:28 UTC
- Message-ID
- <20150527072826.GC6898@peff.net>
- In-Reply-To
- <alpine.DEB.2.10.1505262147230.3709@alice>
On Tue, May 26, 2015 at 09:50:49PM +0100, John Lee wrote:
Show 9 quoted lines
> Does anybody have code to stage commits using a the visual diff/merge tools > supported by git-difftool? Is there support in git itself somewhere, even? > > I'm looking for something functionally similar to git add -p > > Looking at the git-difftool source I can see how to write a command to do > it, but wanted to check if it had already been implemented. > > Did I miss a way that already exists?
git-gui has a visual staging tool, and I think some other git interfaces do, too (e.g., tig). But I don't think there is a way to interact with an arbitrary 3rd-party diff tool. I would think doing so would depend on the diff tool itself; what facility does it provide for picking lines or a hunk out of a diff and communicating it back to git to stage?
If you are interested in looking further, see how the %patch_mode hash is defined in git-add--interactive.perl. Specifically, note that "add -p" is just one case: diff against the index and apply with "apply --cached". But once you have a separate tool for picking hunks, you should be able to drop in the different DIFF/APPLY pairs to implement "checkout -p", etc.
-Peff