Re: [PATCH 7/7] apply --allow-overlap: fix a corner case
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Dec 6, 2019, 17:56 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1912061849300.31080@tvgsbejvaqbjf.bet>
- In-Reply-To
- <xmqqa785xv9w.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Fri, 6 Dec 2019, Junio C Hamano wrote:
Show 9 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > > > The beginning is more special than the end because it is associated with > > the line number 1. The end line number is flexible already. > > Yeah, we do not insist "the lineno must be X" at the end like we do > at the beginning, but we still insist "there cannot be no post > context if we are adding at the end" just like there cannot be any > pre context for a patch that adds at the beginning, no?
True.
Show 7 quoted lines
> > There is another difference: after splitting hunks, the first hunk is > > applied first, and may render the line numbers of succeeding hunks > > incorrect. The same is not true for the last hunk: it cannot render the > > preceding hunks' line numbers incorrect, as it has not been applied yet. > > This truly may make quite a difference, especially because the hunks > are applied in order.
I think you're right, I fooled myself into believing that the line number 1 is special, but the real culprit is that the second hunk is applied _after_ the first one may have changed the (overlapping) context. The same is not true for the second-to-last hunk: it will always be applied before the end of the file can possibly become no longer the end of the file.
I'll try to think up a concise paragraph about this, and stick it into the commit message.
Ciao, Dscho