Function: magit-with-temp-index
magit-with-temp-index is a macro defined in magit-git.el.
Signature
(magit-with-temp-index TREE ARG &rest BODY)
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defmacro magit-with-temp-index (tree arg &rest body)
(declare (indent 2) (debug (form form body)))
(let ((file (gensym "file")))
`(let ((magit--refresh-cache nil)
(,file (magit-convert-filename-for-git
(make-temp-name
(expand-file-name "index.magit." (magit-gitdir))))))
(unwind-protect
(magit-with-toplevel
(when-let* ((tree ,tree)
(_(not (magit-git-success
"read-tree" ,arg tree
(concat "--index-output=" ,file)))))
(error "Cannot read tree %s" tree))
(with-environment-variables (("GIT_INDEX_FILE" ,file))
,@body))
(ignore-errors
(delete-file (concat (file-remote-p default-directory) ,file)))))))