From 54c2a8df3bfaec2141bdf9a11fca59f6d3a58558 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 13 Sep 2020 17:25:08 +0200 Subject: [PATCH] Make diff--refine-hunk bug out less on broken patches * lisp/vc/diff-mode.el (diff--refine-hunk): Don't bug out on broken patches where we can't find the middle. --- lisp/vc/diff-mode.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 1a80d13abde..f223ae48f3b 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2173,9 +2173,10 @@ Return new point, if it was moved." (smerge-refine-regions beg-del beg-add beg-add end-add nil #'diff-refine-preproc props-r props-a))))) ('context - (let* ((middle (save-excursion (re-search-forward "^---" end))) + (let* ((middle (save-excursion (re-search-forward "^---" end t))) (other middle)) - (while (re-search-forward "^\\(?:!.*\n\\)+" middle t) + (while (and middle + (re-search-forward "^\\(?:!.*\n\\)+" middle t)) (smerge-refine-regions (match-beginning 0) (match-end 0) (save-excursion (goto-char other) -- 2.39.5