From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#72556: 29.1.90; vc-diff does not undo hunk in end of source file Date: Sat, 14 Sep 2024 10:35:15 +0300 Message-ID: <86ed5mit70.fsf@gnu.org> References: <87ttfs60ir.fsf@posteo.net> <86ttfj32wk.fsf@gnu.org> <861q2lhrxc.fsf@mail.linkov.net> <86msktcdvj.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30002"; mail-complaints-to="usenet@ciao.gmane.io" Cc: tomasn@posteo.net, 72556@debbugs.gnu.org To: dmitry@gutov.dev, juri@linkov.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 14 09:36:12 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1spNKF-0007cq-Nt for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Sep 2024 09:36:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1spNK4-0005Ps-7R; Sat, 14 Sep 2024 03:36:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1spNK3-0005NM-04 for bug-gnu-emacs@gnu.org; Sat, 14 Sep 2024 03:35:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1spNJv-0000sL-RS for bug-gnu-emacs@gnu.org; Sat, 14 Sep 2024 03:35:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=+090XjaAqF/z3NEN+LV5PRogHfXLHAR6nU1a1Pm5Kwc=; b=a3L3mXlX/4jkzOoIrwaX947aOBsBvrUcgcx+R3qqW+YiBQWe4i5wWzujcoY+S1BjoiWhnr3ulUL3ighrgJI5bfaqz7MYOBiUjObzaAD+28VvYveHiD76QkA6NSmPazVYug3H8OXvZALdxi5pQgWLZsYhJdJXqANNFwma0UACp+rpLRoVcw1lSizFUu4Pwg0ouXK7GJgcXCR71IwWb7BZyDy4S394F0VIpHDHKbZyOx4ZKV73XfxYIEJwtqI+LstXaniJB9Bwje/Z8jDaFxZs7RV8A/Isj7m7APcRaOMk/2saQVjnZSG7I6sRkl9nexdWHsRQnEWR516OUqzbSfEDcw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1spNK6-0002qO-0D for bug-gnu-emacs@gnu.org; Sat, 14 Sep 2024 03:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Sep 2024 07:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72556 X-GNU-PR-Package: emacs Original-Received: via spool by 72556-submit@debbugs.gnu.org id=B72556.172629933610896 (code B ref 72556); Sat, 14 Sep 2024 07:36:01 +0000 Original-Received: (at 72556) by debbugs.gnu.org; 14 Sep 2024 07:35:36 +0000 Original-Received: from localhost ([127.0.0.1]:44658 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spNJf-0002pf-Pk for submit@debbugs.gnu.org; Sat, 14 Sep 2024 03:35:36 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52524) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spNJd-0002pO-QG for 72556@debbugs.gnu.org; Sat, 14 Sep 2024 03:35:34 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1spNJN-0000lz-Of; Sat, 14 Sep 2024 03:35:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+090XjaAqF/z3NEN+LV5PRogHfXLHAR6nU1a1Pm5Kwc=; b=jEIIVMg+fu9y lHdfIRWHUeDPewzXY5D8ju7WExIrvVoVTAopuYv10XeGVv9AQU5RTp3+pnsDM/pdRkDJP+T6AsjYC uV3JlbyX5FZMWs2KfeLqR2R2E32gThZdybC7J/ynUMJZZZmK4cCl90HvZpu4Wemn/gE1eiNxnkZQn ura6EmOnmUBlg8ZPOj2W16uB5rg5SEIaJKTkoxUQiK+xis5GJHVaSMbz5sZohCHayhFQGssIsdlQF adzCFygPlm0hIhHNvfwyxPjaeeEMlgzVLXihC7uppovDWRutBq0xq9r3FEY/+hA2eAMCv8a1dFx3h qjAp4lAfKkHwRyNz0yL2fA==; In-Reply-To: <86msktcdvj.fsf@gnu.org> (message from Eli Zaretskii on Sat, 31 Aug 2024 11:09:36 +0300) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291700 Archived-At: Ping! Would someone want to work on a patch, or should I close this bug as wontfix? > Cc: 72556@debbugs.gnu.org > Date: Sat, 31 Aug 2024 11:09:36 +0300 > From: Eli Zaretskii > > > From: Juri Linkov > > Cc: Tomas Nordin , Dmitry Gutov , > > 72556@debbugs.gnu.org > > Date: Mon, 19 Aug 2024 19:49:05 +0300 > > > > >> To reproduce: > > >> > > >> $ mkdir apply > > >> $ cd apply > > >> $ echo "first line of code" > example.file > > >> $ git init > > >> $ git add . > > >> $ git commit -m 'init' > > >> $ echo "last line of code" >> example.file > > >> $ emacs -Q example.file > > >> > > >> C-x v = > > >> n > > >> C-c C-a > > >> > > >> The hunk is applied in the source buffer. > > > > > > Juri and Dmitry, any comments or suggestions? > > > > I don't know why it fails at the end, so I tried to debug 'diff-apply-hunk', > > and found that the problem is in these lines of 'diff-find-source-location': > > > > ;; FIXME: Check for case where both OLD and NEW are found. > > (pos (or (diff-find-text (car old)) > > > > When the hunk is at the beginning/end of the diff buffer, > > then it misses the top/bottom part of the context, > > so 'diff-find-text' wrongly matches it because it fails > > to see any changes in it due to insufficient context, > > and returns switched=nil. > > > > A possible solution would be to add a condition to detect the case > > when the hunk is at the beginning/end of the diff buffer. > > Thanks. Would anyone like to submit a patch along these lines? > > > >