From 17c831a2cd1118dd9e364d03209d83538926613b Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Tue, 13 May 2025 18:54:50 +0200 Subject: magit-rebase--todo: Don't abbreviate empty set of commits When rebase stops at the last commit, then the list of commits yet to be rebases is (obviously) empty. Don't call "git log --no-walk --format=%h [...]" in that case, because if that is called without any revision arguments, it shows information for HEAD. That resulted in an error because we later assert that the commit and abbreviation lists have the same length. Re #5365. --- lisp/magit-sequence.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el index 5711525..90e352a 100644 --- a/lisp/magit-sequence.el +++ b/lisp/magit-sequence.el @@ -1003,15 +1003,16 @@ status buffer (i.e., the reverse of how they will be applied)." (push obj commits))) (forward-line))) (let ((abbrevs - (magit-git-lines - "log" "--no-walk=unsorted" "--format=%h" - (mapcar (lambda (obj) - (if (eq (oref obj action-type) 'merge) - (let ((options (oref obj action-options))) - (and (string-match "-[cC] \\([^ ]+\\)" options) - (match-string 1 options))) - (oref obj target))) - commits)))) + (and commits + (magit-git-lines + "log" "--no-walk=unsorted" "--format=%h" + (mapcar (lambda (obj) + (if (eq (oref obj action-type) 'merge) + (let ((options (oref obj action-options))) + (and (string-match "-[cC] \\([^ ]+\\)" options) + (match-string 1 options))) + (oref obj target))) + commits))))) (cl-assert (equal (length commits) (length abbrevs))) (while-let ((obj (pop commits)) (val (pop abbrevs))) -- cgit v1.0