From: Johannes Sixt Date: Thu, 13 Dec 2007 07:35:43 GMT Subject: Re: [PATCH] Teach git-gui to split hunks Message-ID: <4760E0CF.1030805@viscovery.net> In-Reply-To: Johannes Schindelin schrieb: > When you select the context menu item "Split Hunk" in the diff area, > git-gui will now split the current hunk so that a new hunk starts at > the current position. > > For this to work, apply has to be called with --unidiff-zero, since > the new hunks can start or stop with a "-" or "+" line. NACK! --unidiff-zero eats your data. 1. Prepare a modification that adds 2 lines that are *not* adjacent, like this: @@ -6,6 +6,8 @@ git-checkout [options] [] [...] -- b= create a new branch started at +first l create the new branch's reflog track arrange that the new branch tracks the remote branch +after track f proceed even if the index or working tree is not HEAD m merge local modifications into the new branch 2. Reduce context to zero. 3. Stage *second* hunk. Result: It is staged at the wrong place: @@ -9,4 +9,5 @@ l create the new branch's reflog track arrange that the new branch tracks the remote branch f proceed even if the index or working tree is not HEAD +after track m merge local modifications into the new branch q,quiet be quiet Reason: --unidiff-zero can only look at the line numbers. And those are wrong because it doesn't account for the shift in line numbers caused by the first hunk. -- Hannes