Function: git-rebase-set-action

git-rebase-set-action is a byte-compiled function defined in git-rebase.el.

Signature

(git-rebase-set-action ACTION)

Documentation

Set action of commit line to ACTION.

If the region is active, operate on all lines that it touches. Otherwise, operate on the current line. As a special case, an ACTION of nil comments or uncomments the rebase line, regardless of its action type.

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/git-rebase.el
(defun git-rebase-set-action (action)
  "Set action of commit line to ACTION.
If the region is active, operate on all lines that it touches.
Otherwise, operate on the current line.  As a special case, an
ACTION of nil comments or uncomments the rebase line, regardless
of its action type."
  (pcase (git-rebase-region-bounds t)
    (`(,beg ,end)
     (let ((end-marker (copy-marker end))
           (pt-below-p (and mark-active (< (mark) (point)))))
       (set-marker-insertion-type end-marker t)
       (goto-char beg)
       (while (< (point) end-marker)
         (with-slots (action-type target trailer comment-p)
             (git-rebase-current-line)
           (cond
             ((and action (eq action-type 'commit))
              (let ((inhibit-read-only t))
                (magit-delete-line)
                (insert (concat action " " target " "))
                (when (magit-git-version>= "2.50.0")
                  (insert "# "))
                (insert (concat trailer "\n"))))
             ((and (not action) action-type)
              (let ((inhibit-read-only t))
                (if comment-p
                    (delete-region beg (+ beg 2))
                  (insert comment-start " ")))
              (forward-line))
             ;; In the case of --rebase-merges, commit lines may have
             ;; other lines with other action types, empty lines, and
             ;; "Branch" comments interspersed.  Move along.
             ((forward-line)))))
       (goto-char (cond (git-rebase-auto-advance end-marker)
                        (pt-below-p (1- end-marker))
                        (beg)))
       (goto-char (line-beginning-position))))
    (_ (ding))))