Re: [PATCH 3/3] add-interactive: add new "context" subcommand
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 7, 2025, 19:10 UTC
- Message-ID
- <xmqqzffob5ji.fsf@gitster.g>
- In-Reply-To
- <a290bc6f-9198-4a00-8273-2970cfbd4a29@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 13 quoted lines
> On 06/05/2025 17:37, Junio C Hamano wrote: >> An alternative that may work better is to allow subcommand specific >> parameters in the answer to the "What now>" prompt, e.g. >> What now> r -U7 >> to choose an equivalent to "git revert -p -U7". > > I think the best solution would be to allow users to re-display the > current hunk with more context inside "add -p" rather than changing > "add -i". That way a user who needs more context to make a decision on > the current hunk can get it without restarting the whole process of > selecting hunks [1]. If the user knows up front that they want a > certain amount of context they can use "git add -p -U <context>" or > "git add -i -U <context>" which was added in the preceding patch.
Yes, but notice that the above is about interactive mode "add -i" that is setting the diff.context to 7 for subsequent "patch" command, not against "Stage this hunk [y,n,q,...]?" prompt inside "add -p". Once you go into the "--patch" mode, especially after you let the user to edit some hunks, "redisplay this hunk with wider context" is an impossible operation with the current code structure, I think, as the implementation does not keep track of information that are needed to do so.
So, this is like "restarting 'add -p' with -U7", but done from the "add -i" session.