Re: [PATCH] Teach git-gui to split hunks
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Dec 13, 2007, 09:41 UTC
- Message-ID
- <4760FE4C.9010806@viscovery.net>
- In-Reply-To
- <7vhcin3rv4.fsf@gitster.siamese.dyndns.org>
Junio C Hamano schrieb:
Show 23 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > >> For this to work, apply has to be called with --unidiff-zero, since >> the new hunks can start or stop with a "-" or "+" line. > > You do not have to do "unidiff zero". Suppose you have this hunk you > need to split. > > diff --git a/read-cache.c b/read-cache.c > index 7db5588..4d12073 100644 > --- a/read-cache.c > +++ b/read-cache.c > @@ -12,8 +12,8 @@ > /* Index extensions. > * > * The first letter should be 'A'..'Z' for extensions that are not > - * necessary for a correct operation (i.e. optimization data). > - * When new extensions are added that _needs_ to be understood in > + * necessary for a correct operation (that is, optimization data). > + * When new extensions are added that needs to be understood in > * order to correctly interpret the index file, pick character that > * is outside the range, to cause the reader to abort. > */
...
Show 7 quoted lines
> That is, , if you want to do finer grained hunk splitting than what "git > add -p" lets you do, you do _not_ let user specify "I want to split the > hunk into two, before this point and after this point". Instead, let > the user pick zero or more '-' line and zero or more '+' line, and > adjust the context around it. An unpicked '-' line becomes the common > context, and an unpicked '+' line disappears. After that, you recount > the diff. That way, you do not have to do any "unidiff zero" cop-out.
In this case I would expect two adjacent hunks: one that covers the selected changes, another one with the remaining changes, but each against the original:
@@ -12,7 +12,7 @@ /* Index extensions. * * The first letter should be 'A'..'Z' for extensions that are not - * necessary for a correct operation (i.e. optimization data). + * necessary for a correct operation (that is, optimization data). * When new extensions are added that _needs_ to be understood in * order to correctly interpret the index file, pick character that * is outside the range, to cause the reader to abort. @@ -13,7 +13,7 @@ * * The first letter should be 'A'..'Z' for extensions that are not * necessary for a correct operation (i.e. optimization data). - * When new extensions are added that _needs_ to be understood in + * When new extensions are added that needs to be understood in * order to correctly interpret the index file, pick character that * is outside the range, to cause the reader to abort. */ Then I can stage either one. After that operation, git-gui refreshes the patch display. This is now the time where the hunk that was not staged should be updated to reflect the correct diff against the staged hunk. -- Hannes