Function: magit-wip-commit-worktree

magit-wip-commit-worktree is a byte-compiled function defined in magit-wip.el.

Signature

(magit-wip-commit-worktree REF FILES MSG)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-wip.el
(defun magit-wip-commit-worktree (ref files msg)
  (when (or (not files)
            ;; "git update-index" either ignores (before Git v2.32.0) or
            ;; fails, when passed directories.  This is relevant for the
            ;; untracked files code paths.
            (setq files (seq-remove #'file-directory-p files)))
    (let* ((wipref (magit--wip-wtree-ref ref))
           (parent (magit-wip-get-parent ref wipref))
           (tree (condition-case nil
                     (magit-with-temp-index parent (list "--reset" "-i")
                       (if files
                           ;; Use "git update-index" instead of "git add"
                           ;; because the latter fails if a file is already
                           ;; deleted in the temporary index.
                           (magit-wip--git "update-index" "--add" "--remove"
                                           "--ignore-skip-worktree-entries"
                                           "--" files)
                         (magit-with-toplevel
                           (magit-wip--git "add" "-u" ".")))
                       (magit-git-string "write-tree"))
                   (error
                    (message "Index locked; no worktree wip commit created")))))
      (when tree
        (magit-wip-update-wipref ref wipref tree parent
                                 files msg "worktree")))))