Download raw body.
got rebase or diff library bug
On Mon, Aug 05, 2024 at 10:26:13PM +1000, Mark Jamsek wrote:
> Mark Jamsek <mark@jamsek.com> wrote:
> > Christian Weisgerber <naddy@mips.inka.de> wrote:
> > > Christian Weisgerber:
> > >
> > > > It also fixes my original problem. I rebased the llvm18 branch in
> > > > my repository and the GCNRegPressure.cpp file survived unscathed.
> > >
> > > Wait, no, it gained a trailing '\n':
> >
> > Thanks, naddy! I was worried about that case.
> >
> > I'll see if if I can come up with a minimal repro and a proper fix.
>
> I've not yet managed to produce a minimal reproduction of your llvm case
> such that the trailing newline is appended with the previous diff, but
> I'm pretty sure I know why it's happening: it's because the ed script is
> not necessarily generated in order so we end up unsetting no_eofnl.
>
> If I'm right, the below diff should now work with your llvm merge and
> it's still working with the simple hello\nworld\n+fubarEOF case.
>
> Please let me know if GCNRegPressure.cpp still survives your llvm rebase
> unscathed and without gaining the trailing '\n', and I'll keep working
> on a minimal test case for it too. Thanks, naddy!
>
fix is ok by me, thanks!
> diffstat f997e889eb0517a24a28f2f4000d6915683fef86 de493b727770ab0c07070cc9aff938371f4e4132
> M lib/diff3.c | 17+ 0-
>
> 1 file changed, 17 insertions(+), 0 deletions(-)
>
> diff f997e889eb0517a24a28f2f4000d6915683fef86 de493b727770ab0c07070cc9aff938371f4e4132
> commit - f997e889eb0517a24a28f2f4000d6915683fef86
> commit + de493b727770ab0c07070cc9aff938371f4e4132
> blob - c1ca2fdf44d461cda6adb950263ed6a9775971ac
> blob + 870a8eac2fb905a8f66de48e38c247aa970d2c5e
> --- lib/diff3.c
> +++ lib/diff3.c
> @@ -155,6 +155,8 @@ struct diff3_state {
>
> char *buf;
>
> + int no_eofnl; /* set if the merged file has no eof newline */
> +
> BUF *diffbuf;
> };
>
> @@ -417,6 +419,10 @@ out:
> err = got_error_from_errno("fclose");
> }
> if (err == NULL && diffb) {
> + dlen = buf_len(diffb);
> + if (d3s->no_eofnl && dlen > 0 &&
> + buf_getc(diffb, dlen - 1) == '\n')
> + --diffb->cb_len;
> if (buf_write_fd(diffb, outfd) < 0)
> err = got_error_from_errno("buf_write_fd");
> *overlapcnt = d3s->overlapcnt;
> @@ -1063,6 +1069,17 @@ edscript(int n, struct diff3_state *d3s)
> }
>
> if (!d3s->overlap[n]) {
> + size_t len;
> +
> + len = buf_len(d3s->diffbuf);
> + if (len > 0) {
> + if (buf_getc(d3s->diffbuf, len - 1) != '\n') {
> + err = buf_putc(d3s->diffbuf, '\n');
> + if (err != NULL)
> + goto done;
> + d3s->no_eofnl = 1;
> + }
> + }
> err = diff_output(d3s->diffbuf, ".\n");
> if (err)
> goto done;
>
>
> --
> Mark Jamsek <https://bsdbox.org>
> GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
>
>
got rebase or diff library bug