Re: Unified workflow for `git add/checkout --patch`?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tim

On 21/10/2021 23:19, Timothy Eccleston wrote:
Hi,
I really like both these features:
- git add -p
- git checkout -p

My typical workflow
I like to use them after a long and complex coding sessions where I
want to double-check my work, making edits and adding sets of patches
into sequential commits to keep related changes together topically.

In the process of using git add -p to grab some patches, I may notice
other patches I don't want (especially after I've used the "e" command
in `git add -p` to edit a patch - I usually want to drop the
remaining, unstaged version of the patch right then). But, instead, I
have to go through git add -p and then git checkout -p and likely back
and forth several times, each time skipping through all the same
undecided or postponed patches I am waiting on for later.

Note: I recently discovered the "j" and "J" subcommands which are
useful to postpone decisions on certain patches, but only if I
restrict myself to just git add or git checkout. If I want to do both,
I still have to cycle back through from the top each time. I suppose I
could use stash -p to really hide patches I'm saving for later, but I
still have to exit my workflow and start another command, requiring
multiple passes. OTOH, a unified git add/checkout/stash --patch would
be amazing!

My request
It would be really nice if there were a unified command workflow where
I could add or checkout patches or even partial patches (after editing
a patch in git add), on a case by case basis in a single pass.

I think I kind of see what you want but I'm a bit confused as how it could be implemented. To clarify do you want to checkout the index to discard the changes in the worktree or checkout HEAD (the later would be difficult as 'add -p' shows the differences between the index and the worktree)? Have you any thoughts on how the user would select whether to add a change to the index or discard it from the worktree? It gets a bit tricky if you want to stage an edited version of a hunk and discard the unstaged portion from the worktree but I guess we could apply the reverse of the original hunk to discard all the changes and then apply the staged version of the hunk to get just the changes the user wants. I think the main challenge would be with the user interface.

Best Wishes

Phillip

Does anyone know a way to do this or do you think it's worth making a
new feature in git to handle it?

Thanks!
Tim





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux