Function: magit--gitignore

magit--gitignore is a byte-compiled function defined in magit-gitignore.el.

Signature

(magit--gitignore RULE FILE &optional STAGE)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-gitignore.el
(defun magit--gitignore (rule file &optional stage)
  (when$ (file-name-directory file)
    (make-directory $ t))
  (with-temp-buffer
    (when (file-exists-p file)
      (insert-file-contents file))
    (goto-char (point-max))
    (unless (bolp)
      (insert "\n"))
    (insert (replace-regexp-in-string "\\(\\\\*\\)" "\\1\\1" rule))
    (insert "\n")
    (write-region nil nil file))
  (if stage
      (magit-with-toplevel
        (magit-run-git "add" (magit-convert-filename-for-git file)))
    (magit-refresh)))