Re: [PATCH v2 1/1] Allow reworking with a file after deciding on all its hunks
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 31, 2026, 19:25 UTC
- Message-ID
- <xmqqqzr54mam.fsf@gitster.g>
- In-Reply-To
- <CADYq+fbt7zHO=gAsRp=b5MTb=2aFfifCjWnW6u+58iv4dk6bMQ@mail.gmail.com>
Samuel Abraham <abrahamadekunle50@gmail.com> writes:
Show 11 quoted lines
>> 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?
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.
Thanks.