Function: magit-todos--maybe-insert-branch-todos

magit-todos--maybe-insert-branch-todos is a natively compiled function defined in magit-todos.el.

Signature

(magit-todos--maybe-insert-branch-todos &optional TYPE)

Documentation

Insert branch todos when appropriate.

If TYPE is rescan, rescan for items; if cached, only insert cached items, if any; otherwise, use cached items if any, or rescan.

Source Code

;; Defined in /nix/store/xy37aj9089qvbs5clw0qszpi3hrh3mxx-emacs-packages-deps/share/emacs/site-lisp/elpa/magit-todos-20250928.1611/magit-todos.el
(defun magit-todos--maybe-insert-branch-todos (&optional type)
  "Insert branch todos when appropriate.
If TYPE is `rescan', rescan for items; if `cached', only insert
cached items, if any; otherwise, use cached items if any, or
rescan."
  (when (or (eq magit-todos-branch-list t)
            (and (eq magit-todos-branch-list 'branch)
                 (not (equal (or magit-todos-branch-list-merge-base-ref (magit-main-branch))
                             (magit-get-current-branch)))))
    (if (or (eq 'rescan type)
            (and (not (eq 'cached type))
                 (null magit-todos-branch-item-cache)))
        ;; TODO: Refactor to just return items and then insert separately.
        (magit-todos--scan-with-git-diff
         :magit-status-buffer (current-buffer)
         :directory default-directory
         :depth magit-todos-depth
         :heading (format "TODOs (branched from %s)"
                          (or magit-todos-branch-list-merge-base-ref (magit-main-branch))))
      ;; Just insert cached items, if any.
      (let ((magit-todos-section-heading
             (format "TODOs (branched from %s)"
                     (or magit-todos-branch-list-merge-base-ref (magit-main-branch)))))
        (magit-todos--insert-items (current-buffer) magit-todos-branch-item-cache :branch-p t)))))