git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Staging commits with visual diff tools?
@ 2015-05-26 20:50 John Lee
  2015-05-27  7:28 ` Jeff King
  2015-05-31  1:59 ` David Aguilar
  0 siblings, 2 replies; 10+ messages in thread
From: John Lee @ 2015-05-26 20:50 UTC (permalink / raw)
  To: git

Hi

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?

Thanks


John

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Staging commits with visual diff tools?
  2015-05-26 20:50 Staging commits with visual diff tools? John Lee
@ 2015-05-27  7:28 ` Jeff King
  2015-05-27  7:34   ` John Lee
  2015-05-31  1:59 ` David Aguilar
  1 sibling, 1 reply; 10+ messages in thread
From: Jeff King @ 2015-05-27  7:28 UTC (permalink / raw)
  To: John Lee; +Cc: git

On Tue, May 26, 2015 at 09:50:49PM +0100, John Lee wrote:

> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Staging commits with visual diff tools?
  2015-05-27  7:28 ` Jeff King
@ 2015-05-27  7:34   ` John Lee
  2015-05-29  9:57     ` Michael J Gruber
  0 siblings, 1 reply; 10+ messages in thread
From: John Lee @ 2015-05-27  7:34 UTC (permalink / raw)
  To: git

On Wed, 27 May 2015, Jeff King wrote:

> 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.

My plan was to use symlinks, checkout-index, and update-index 
--index-info, similar to how difftool does it.  I verified on the command 
line that that seems to work.


John

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Staging commits with visual diff tools?
  2015-05-27  7:34   ` John Lee
@ 2015-05-29  9:57     ` Michael J Gruber
  0 siblings, 0 replies; 10+ messages in thread
From: Michael J Gruber @ 2015-05-29  9:57 UTC (permalink / raw)
  To: John Lee, git, Jeff King

John Lee venit, vidit, dixit 27.05.2015 09:34:
> On Wed, 27 May 2015, Jeff King wrote:
> 
>> 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.
> 
> My plan was to use symlinks, checkout-index, and update-index 
> --index-info, similar to how difftool does it.  I verified on the command 
> line that that seems to work.
> 
> 
> John
> 

Yes, having "git addtool" (or "stagetool") to go with difftool and merge
tool would be nice, and it could hopefully resuse code or infrastructure
from those tools, as well as the tool config.

I vaguely remember a sketch or proof-of-concept by Jeff (not reusing
*tool) but may be wrong.

Michael

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Staging commits with visual diff tools?
  2015-05-26 20:50 Staging commits with visual diff tools? John Lee
  2015-05-27  7:28 ` Jeff King
@ 2015-05-31  1:59 ` David Aguilar
  2015-05-31  9:36   ` John Lee
  1 sibling, 1 reply; 10+ messages in thread
From: David Aguilar @ 2015-05-31  1:59 UTC (permalink / raw)
  To: John Lee; +Cc: git

On Tue, May 26, 2015 at 09:50:49PM +0100, John Lee wrote:
> Hi
> 
> 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?
> 
> Thanks
> 
> 
> John

If you're interested in existing staging tools then I would
highly suggest looking at git-cola.

    https://github.com/git-cola/git-cola

    git clone git://github.com/git-cola/git-cola.git

git-cola is free software so it's pretty unique in many ways.
I also wrote it, so that makes it that much more awesome ;-)

cola has a very slick interactive staging editor, interactive
rebase, and a whole lot more.

I'm a g/vim user, so git-cola is finely tuned for keyboard
usage.  If we implement these feature in Git, we should consider
providing the same workflows/hotkeys as cola.

For staging, you can select lines, hit "s", and they'll be
staged/unstaged.  ctrl-u reverts unstaged edits, etc.
The '?' hotkey shows the help, etc.

You can get extremely granular, moreso then "add -p", which is
why it exists.  When cola's diff editor is not sufficient, you
can also use it to drive difftool, but only in ways that you can
on the command-line already.

git-cola is written in Python(2+3) so it's easy to hack on, and
quite portable.

cheers,
-- 
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Staging commits with visual diff tools?
  2015-05-31  1:59 ` David Aguilar
@ 2015-05-31  9:36   ` John Lee
  2015-06-01  2:25     ` David Aguilar
  0 siblings, 1 reply; 10+ messages in thread
From: John Lee @ 2015-05-31  9:36 UTC (permalink / raw)
  To: git

On Sat, 30 May 2015, David Aguilar wrote:

> On Tue, May 26, 2015 at 09:50:49PM +0100, John Lee wrote:
>> Hi
>>
>> Does anybody have code to stage commits using a the visual
>> diff/merge tools supported by git-difftool?  Is there support in git
...
> I'm a g/vim user, so git-cola is finely tuned for keyboard
> usage.  If we implement these feature in Git, we should consider
> providing the same workflows/hotkeys as cola.

Just to be clear I'm not planning on contributing my script back to git, 
it will just be a standalone script in a separate repo.

I'll give git-cola a try, thanks.  I just ran it and see it supports e.g. 
right click to stage and launching difftools -- does it also support 
launching a difftool to edit the index?


John

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Staging commits with visual diff tools?
  2015-05-31  9:36   ` John Lee
@ 2015-06-01  2:25     ` David Aguilar
  2015-06-01 19:36       ` John Lee
  0 siblings, 1 reply; 10+ messages in thread
From: David Aguilar @ 2015-06-01  2:25 UTC (permalink / raw)
  To: John Lee; +Cc: git

On Sun, May 31, 2015 at 10:36:52AM +0100, John Lee wrote:
> On Sat, 30 May 2015, David Aguilar wrote:
> 
> >On Tue, May 26, 2015 at 09:50:49PM +0100, John Lee wrote:
> >>Hi
> >>
> >>Does anybody have code to stage commits using a the visual
> >>diff/merge tools supported by git-difftool?  Is there support in git
> ...
> >I'm a g/vim user, so git-cola is finely tuned for keyboard
> >usage.  If we implement these feature in Git, we should consider
> >providing the same workflows/hotkeys as cola.
> 
> Just to be clear I'm not planning on contributing my script back to
> git, it will just be a standalone script in a separate repo.
> 
> I'll give git-cola a try, thanks.  I just ran it and see it supports
> e.g. right click to stage and launching difftools -- does it also
> support launching a difftool to edit the index?

If you have stuff staged and use ctrl-d (or right-click->difftool),
git cola will run, "git difftool --staged -- <path>".

difftool will already point back to your worktree whenever
possible through the GIT_EXTERNAL_DIFF machinery that it uses.

After changes are made in the worktree you select files, lines,
or hunks and stage them.  Doing it in one step could be as
simple as having a script to automatically call "git add" after
difftool, or "ctrl-s" in cola to stage the whole file.

A not as simple (but potentially quite helpful) use case is a
tool that does a 3-way merge between HEAD, index, and worktree,
and writes the result back to the worktree (or index?).
The mergetool--lib backend could be leveraged for that feature.

Were you thinking of something like this, or something else?
Can you describe your use case a bit more?

It seems like we have most of the use cases covered with stock
git, but I'm not sure if I'm missing something.

cheers,
-- 
David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Staging commits with visual diff tools?
  2015-06-01  2:25     ` David Aguilar
@ 2015-06-01 19:36       ` John Lee
  2015-06-27 23:23         ` John Lee
  0 siblings, 1 reply; 10+ messages in thread
From: John Lee @ 2015-06-01 19:36 UTC (permalink / raw)
  To: git

On Sun, 31 May 2015, David Aguilar wrote:
> Were you thinking of something like this, or something else?
> Can you describe your use case a bit more?

I think now I should just publish my script and then it will be very clear 
what I'm talking about.  If somebody then wants to add a similar feature 
to git-cola, or even git itself, that would be great.


John

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Staging commits with visual diff tools?
  2015-06-01 19:36       ` John Lee
@ 2015-06-27 23:23         ` John Lee
  2015-06-28 17:56           ` John Lee
  0 siblings, 1 reply; 10+ messages in thread
From: John Lee @ 2015-06-27 23:23 UTC (permalink / raw)
  To: git

On Mon, 1 Jun 2015, John Lee wrote:

> On Sun, 31 May 2015, David Aguilar wrote:
>> Were you thinking of something like this, or something else?
>> Can you describe your use case a bit more?
>
> I think now I should just publish my script and then it will be very clear 
> what I'm talking about.  If somebody then wants to add a similar feature to 
> git-cola, or even git itself, that would be great.
>
>
> John
>

Here it is:

https://github.com/jjlee/git-meld-index

Hasn't seen use for real yet, so be a bit cautious with it.

Comments / patches / whatever appreciated.


John

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Staging commits with visual diff tools?
  2015-06-27 23:23         ` John Lee
@ 2015-06-28 17:56           ` John Lee
  0 siblings, 0 replies; 10+ messages in thread
From: John Lee @ 2015-06-28 17:56 UTC (permalink / raw)
  To: git

On Sun, 28 Jun 2015, John Lee wrote:

> Here it is:
>
> https://github.com/jjlee/git-meld-index
>
> Hasn't seen use for real yet, so be a bit cautious with it.
>
> Comments / patches / whatever appreciated.
>
>
> John
>

By the way despite the name it should support all git difftools (it uses 
the same git config parameters and git-mergetool--lib code as git itself).

I just used it to make some changes to its own project, quite nice :-)

It now has a --help manpage and some relevant options from git-difftool.


John

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-06-28 17:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-26 20:50 Staging commits with visual diff tools? John Lee
2015-05-27  7:28 ` Jeff King
2015-05-27  7:34   ` John Lee
2015-05-29  9:57     ` Michael J Gruber
2015-05-31  1:59 ` David Aguilar
2015-05-31  9:36   ` John Lee
2015-06-01  2:25     ` David Aguilar
2015-06-01 19:36       ` John Lee
2015-06-27 23:23         ` John Lee
2015-06-28 17:56           ` John Lee

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).