From: Christian Weisgerber Subject: Re: new diff implementation To: gameoftrees@openbsd.org Date: Fri, 23 Oct 2020 16:40:41 +0200 Stefan Sperling: > The patch below was generated with the new diff code :) Which already reveals a problem. The patch doesn't apply, because this hunk... > --- lib/diff.c > +++ lib/diff.c [...] > @@ -796,8 +834,20 @@ got_diff_objects_as_trees(struct got_object_id *id1, s > arg.diff_context = diff_context; > arg.ignore_whitespace = ignore_whitespace; > arg.outfile = outfile; > + if (want_lineoffsets) { > + arg.line_offsets = *line_offsets; > + arg.nlines = *nlines; > + } else { > + arg.line_offsets = NULL; > + arg.nlines = 0; > + } > err = got_diff_tree(tree1, tree2, label1, label2, repo, > - got_diff_blob_output_unidiff, &arg, 1); > + got_diff_blob_output_unidiff, &arg, 1); > + > + if (want_lineoffsets) { > + *line_offsets = arg.line_offsets; /* was likely re-allocated */ > + *nlines = arg.nlines; > + } > got_diff_blob_output_unidiff, &arg, 1); > done: > if (tree1) > got_object_tree_close(tree1); ... ends with an extraneous line and patch(1) becomes very confused: |blob - 7e5ee06994a5158bc937ce8307bd19f51d7e0ef5 |blob + 9ed331be5c5b709d71129cb883b6c47a9f9c6a96 |--- lib/diff.c |+++ lib/diff.c -------------------------- Patching file lib/diff.c using Plan A... Hunk #1 succeeded at 17. Hunk #2 succeeded at 40. Hunk #3 succeeded at 89. Hunk #4 succeeded at 111. Hunk #5 succeeded at 136. Hunk #6 succeeded at 202. Hunk #7 succeeded at 243. Hunk #8 succeeded at 288. Hunk #9 succeeded at 776. Hunk #10 succeeded at 797. Hunk #11 succeeded at 808. Hunk #12 failed at 834. 1 out of 12 hunks failed Hmm... The next patch looks like a unified diff to me... The text leading up to this was: -------------------------- | got_object_tree_close(tree1); -------------------------- File to patch: No file found--skip this patch? [n] patch: **** can't find got_object_tree_close(tree1); -- Christian "naddy" Weisgerber naddy@mips.inka.de