git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Stage or discard a hunk at a time?
@ 2019-01-16 19:09 Cameron Steffen
  2019-04-22 19:28 ` Jeff King
  2019-04-28  8:47 ` David Aguilar
  0 siblings, 2 replies; 4+ messages in thread
From: Cameron Steffen @ 2019-01-16 19:09 UTC (permalink / raw)
  To: git

Hello,

I have this feature idea for git. There should be a command that
effectively combines git add -p and git checkout -p so that I can
navigate changed hunks and either stage or discard them.

There is already a SO question asking about this exactly...
https://stackoverflow.com/questions/11538650/simultaneously-git-add-p-and-git-checkout-p

Has this been discussed before? Is this a reasonable request? If so, I
might look into contributing the change myself.

Cameron

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

* Re: Stage or discard a hunk at a time?
  2019-01-16 19:09 Stage or discard a hunk at a time? Cameron Steffen
@ 2019-04-22 19:28 ` Jeff King
  2019-04-30 23:19   ` Johannes Schindelin
  2019-04-28  8:47 ` David Aguilar
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff King @ 2019-04-22 19:28 UTC (permalink / raw)
  To: Cameron Steffen; +Cc: git

On Wed, Jan 16, 2019 at 01:09:03PM -0600, Cameron Steffen wrote:

> I have this feature idea for git. There should be a command that
> effectively combines git add -p and git checkout -p so that I can
> navigate changed hunks and either stage or discard them.
> 
> There is already a SO question asking about this exactly...
> https://stackoverflow.com/questions/11538650/simultaneously-git-add-p-and-git-checkout-p
> 
> Has this been discussed before? Is this a reasonable request? If so, I
> might look into contributing the change myself.

This is something I've sometimes wanted, too. I don't think it would be
_too_ hard to do by modifying the add-interactive code. Both of those
operations are driven by the same code; see the %patch_modes hash in
git-add--interactive.perl, which defines the various situations. You
would need to modify the actual code to handle the tri-state (there is
not just "yes, apply it" and "no, leave it alone", but now "apply /
discard / skip"). But it seems do-able.

If you do plan to work on it, be aware that the perl bits of
add--interactive are being re-written in C. So it might make sense to
target the new C implementation instead of modifying the perl.

-Peff

PS Sorry for the slow reply, and I hope you're still interested in the
   topic. Your message got throw onto my "interesting, should reply"
   pile and I just happened to see it while clearing out old mails. :)

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

* Re: Stage or discard a hunk at a time?
  2019-01-16 19:09 Stage or discard a hunk at a time? Cameron Steffen
  2019-04-22 19:28 ` Jeff King
@ 2019-04-28  8:47 ` David Aguilar
  1 sibling, 0 replies; 4+ messages in thread
From: David Aguilar @ 2019-04-28  8:47 UTC (permalink / raw)
  To: Cameron Steffen; +Cc: git

On Wed, Jan 16, 2019 at 01:09:03PM -0600, Cameron Steffen wrote:
> Hello,
> 
> I have this feature idea for git. There should be a command that
> effectively combines git add -p and git checkout -p so that I can
> navigate changed hunks and either stage or discard them.
> 
> There is already a SO question asking about this exactly...
> https://stackoverflow.com/questions/11538650/simultaneously-git-add-p-and-git-checkout-p
> 
> Has this been discussed before? Is this a reasonable request? If so, I
> might look into contributing the change myself.
> 
> Cameron

Install Git Cola.

It's a powerful Git GUI with a keyboard-centric workflow.
You can do this completely through keyboard shortcuts
(or a mouse if you prefer).

Typically:

	$ git cola

	ctrl-k: focus the status widget
	j,k: navigate up/down the file list
	ctrl-s: stage files
	ctrl-u: revert files to index

	ctrl-j: focus the diff widget to operate at the line/hunk level
	j, k: move the cursor up/down lines, hold shift to select lines
	s: to stage selection, or current hunk if no lines are selected
	ctrl-u: revert the selection, or current hunk, to match the index

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

https://git-cola.github.io/downloads.html
-- 
David

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

* Re: Stage or discard a hunk at a time?
  2019-04-22 19:28 ` Jeff King
@ 2019-04-30 23:19   ` Johannes Schindelin
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2019-04-30 23:19 UTC (permalink / raw)
  To: Jeff King; +Cc: Cameron Steffen, git

Hi,

On Mon, 22 Apr 2019, Jeff King wrote:

> On Wed, Jan 16, 2019 at 01:09:03PM -0600, Cameron Steffen wrote:
>
> > I have this feature idea for git. There should be a command that
> > effectively combines git add -p and git checkout -p so that I can
> > navigate changed hunks and either stage or discard them.
> >
> > There is already a SO question asking about this exactly...
> > https://stackoverflow.com/questions/11538650/simultaneously-git-add-p-and-git-checkout-p
> >
> > Has this been discussed before? Is this a reasonable request? If so, I
> > might look into contributing the change myself.
>
> This is something I've sometimes wanted, too. I don't think it would be
> _too_ hard to do by modifying the add-interactive code. Both of those
> operations are driven by the same code; see the %patch_modes hash in
> git-add--interactive.perl, which defines the various situations. You
> would need to modify the actual code to handle the tri-state (there is
> not just "yes, apply it" and "no, leave it alone", but now "apply /
> discard / skip"). But it seems do-able.
>
> If you do plan to work on it, be aware that the perl bits of
> add--interactive are being re-written in C. So it might make sense to
> target the new C implementation instead of modifying the perl.

The work on that is tracked in PRs 170-175 on
https://github.com/gitgitgadget/git, i.e.

- https://github.com/gitgitgadget/git/pull/170
- https://github.com/gitgitgadget/git/pull/171
- https://github.com/gitgitgadget/git/pull/172
- https://github.com/gitgitgadget/git/pull/173
- https://github.com/gitgitgadget/git/pull/174
- https://github.com/gitgitgadget/git/pull/175

Ciao,
Johannes

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

end of thread, other threads:[~2019-04-30 23:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 19:09 Stage or discard a hunk at a time? Cameron Steffen
2019-04-22 19:28 ` Jeff King
2019-04-30 23:19   ` Johannes Schindelin
2019-04-28  8:47 ` David Aguilar

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 NNTP newsgroup(s).