Function: magit-sequence-insert-sequence

magit-sequence-insert-sequence is a byte-compiled function defined in magit-sequence.el.

Signature

(magit-sequence-insert-sequence STOP ONTO &optional ORIG)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-sequence.el
(defun magit-sequence-insert-sequence (stop onto &optional orig)
  (let ((head (magit-rev-parse "HEAD")) done)
    (setq onto (if onto (magit-rev-parse onto) head))
    (setq done (mapcar (##split-string % "\0")
                       (magit-git-lines "log" "--format=%H%x00%h%x00%s"
                                        (concat onto "..HEAD"))))
    (when (and stop (not (assoc (magit-rev-parse stop) done)))
      (let ((id (magit-patch-id stop)))
        (if-let ((matched (car (assoc (##equal (magit-patch-id %) id) done))))
            (setq stop matched)
          (cond
            ((assoc (##magit-rev-equal % stop) done)
             ;; The commit's testament has been executed.
             (magit-sequence-insert-commit "void" stop 'magit-sequence-drop))
            ;; The faith of the commit is still undecided...
            ((magit-anything-unmerged-p)
             ;; ...and time travel isn't for the faint of heart.
             (magit-sequence-insert-commit "join" stop 'magit-sequence-part))
            ((magit-anything-modified-p t)
             ;; ...and the dust hasn't settled yet...
             (magit-sequence-insert-commit
              (let* ((magit--refresh-cache nil)
                     (staged   (magit-commit-tree "oO" nil "HEAD"))
                     (unstaged (magit-commit-worktree "oO" "--reset")))
                (cond
                  ;; ...but we could end up at the same tree just by committing.
                  ((or (magit-rev-equal staged   stop)
                       (magit-rev-equal unstaged stop))
                   "goal")
                  ;; ...but the changes are still there, untainted.
                  ((or (equal (magit-patch-id staged)   id)
                       (equal (magit-patch-id unstaged) id))
                   "same")
                  ;; ...and some changes are gone and/or others were added.
                  ("work")))
              stop 'magit-sequence-part))
            ;; The commit is definitely gone...
            ((assoc (##magit-rev-equal % stop) done)
             ;; ...but all of its changes are still in effect.
             (magit-sequence-insert-commit "poof" stop 'magit-sequence-drop))
            ;; ...and some changes are gone and/or other changes were added.
            ((magit-sequence-insert-commit "gone" stop 'magit-sequence-drop)))
          (setq stop nil))))
    (pcase-dolist (`(,rev ,abbrev ,msg) done)
      (apply #'magit-sequence-insert-commit
             (cond ((equal rev stop)
                    ;; ...but its reincarnation lives on.
                    ;; Or it didn't die in the first place.
                    (list (if (and (equal rev head)
                                   (equal (magit-patch-id rev)
                                          (magit-patch-id orig)))
                              "stop" ; We haven't done anything yet.
                            "like")  ; There are new commits.
                          rev (if (equal rev head)
                                  'magit-sequence-head
                                'magit-sequence-stop)
                          abbrev msg))
                   ((equal rev head)
                    (list "done" rev 'magit-sequence-head abbrev msg))
                   ((list "done" rev 'magit-sequence-done abbrev msg)))))
    (magit-sequence-insert-commit "onto" onto
                                  (if (equal onto head)
                                      'magit-sequence-head
                                    'magit-sequence-onto))))