Subject: bug#35624: log-view-diff regression

From: Juri Linkov <[email-masked]>
Date: Wed, 08 May 2019 22:52:41 +0300

> I think the patch should look like the one below instead. Does it fix your
> problem? It also looks "obviously correct" in my opinion.

This is exactly what was my initial thought, but this is a wrong fix,
as I realized later.

> diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el
> index e47fad8908..e1e453115b 100644
> --- a/lisp/vc/log-view.el
> +++ b/lisp/vc/log-view.el
> @@ -621,7 +621,8 @@ log-view-diff-common
>                (>= (point)
>                    (save-excursion
>                      (goto-char (car fr-entry))
> -                    (forward-line))))
> +                    (forward-line)
> +                    (point))))
>        (setq fr (vc-call-backend log-view-vc-backend 'previous-revision nil fr)))
>      (vc-diff-internal
>       t (list log-view-vc-backend

This patch doesn't check if the region's end is after the last revision,
also fails if the summary line is expanded to multiline revision's header/body.

> Your proposal would fail in the presence of "Show 2X entries" (when the log
> is long enough).

Yes, I know my previous patch is not perfect, I also tried

  (not (re-search-forward log-view-message-re nil t))

but it seems this is impossible to do because currently
log-view.el doesn't support the notion of the end of
the last revision expanded body.  For example,

1. with the expanded last visible revision

  * h8..: 2019-05-08 Revision h8.
b * g7..: 2019-05-07 Revision g7.
  * f6..: 2019-05-06 Revision f6.
  * e5..: 2019-05-05 Revision e5.
  commit e5
  Date:   2019-05-05
  first line
  second line
e third line

should compare e5 and g7

2. but when region's end (e) is after the last line
   of the last expanded revision:

  * h8..: 2019-05-08 Revision h8.
b * g7..: 2019-05-07 Revision g7.
  * f6..: 2019-05-06 Revision f6.
  * e5..: 2019-05-05 Revision e5.
  commit e5
  Date:   2019-05-05
  first line
  second line
  third line
e

should compare d4 (a previous revision of the last revision) and g7.