Re: [PATCH v2 1/1] Allow reworking with a file after deciding on all its hunks
- From
Samuel Abraham <abrahamadekunle50@gmail.com>
- Date
- Feb 2, 2026, 11:14 UTC
- Message-ID
- <CADYq+fZFuvCRbFf=-XUR8TJsjW_YtjNdiXMzPv0mjMPbWcLO1g@mail.gmail.com>
- In-Reply-To
- <xmqqqzr54mam.fsf@gitster.g>
On Sat, Jan 31, 2026 at 8:25 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 27 quoted lines
> > Samuel Abraham <abrahamadekunle50@gmail.com> writes: > > >> What I observed after adding the '>' and '<' options is that if a user chooses > >> to use a hunk A in file 1, and then goes to file 2 with '>', comes back to > >> file 1 with '<', and decides on hunk A to skip it instead, because > >> patch_update_file() has > >> applied the file with the hunk the user initially decided to use > >> before proceeding to file > >> 2 with '>', coming back to redecide and say skip does not apply the > >> latest decision > >> and when you check the index, the file with the hunks which the user > >> initially decided to > >> use but changed to skip is present in the index. > > I am not sure if I would like the end result or rather prefer your > "all-or-none", so please do not take this as "here is a better way > to implement it" suggestion. > > But you should be able to keep the current semantics, if you wanted > to, even if you apply the chosen hunks when you switch files, like > the original code has been doing forever since it was written. You > know which hunks you applied, so after applying before moving on to > the next file, you can drop these hunks from the list of hunks to be > decided for application. When the user comes back to the current > file to decide on other hunks, you know that the already used hunks > would get in the way, so why keep them?
Yes thank you so much for suggesting this approach.
Show 11 quoted lines
> > Having said that, I think the all-or-none mode may be handy if one > makes the current working tree dirty with many little unrelated and > insignificant changes and the only way to make sense is to see the > "git diff --cached" output after adding some and leaving others, at > least in the way some people work. I usually am very incremental > when doing "git add -p", in that while using the command in one > terminal, I run "git diff --cached" to see if I added unwanted > things by mistake and "git diff" to see if I left out necessary > things, so I would probably not be using the mode. But that is just > my hunch without using the new interface long enough.
Okay I think retaining "git apply" in patch_update_file() and dropping the hunks the user has already decided on when coming back to the file makes sense. By using this approach, we skip files that have been fully decided and applied, only showing files that; i. have been applied but also have undecided hunks. ii. not been applied and still have undecided hunks when the user navigates with ">" and "<".
This will allow you to still run git diff--cached to see what has been added while also being able to see what has not been added, while navigating around files.
Thank you. Abraham