Function: magit-submodule--maybe-reuse-gitdir

magit-submodule--maybe-reuse-gitdir is a byte-compiled function defined in magit-submodule.el.

Signature

(magit-submodule--maybe-reuse-gitdir NAME PATH)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-submodule.el
;;; Utilities

(defun magit-submodule--maybe-reuse-gitdir (name path)
  (let ((gitdir (convert-standard-filename
                 (expand-file-name (concat "modules/" name)
                                   (magit-gitdir)))))
    (when (and (file-exists-p gitdir)
               (not (file-exists-p path)))
      (pcase (read-char-choice
              (concat
               gitdir " already exists.\n"
               "Type [u] to use the existing gitdir and create the working tree\n"
               "     [r] to rename the existing gitdir and clone again\n"
               "     [t] to trash the existing gitdir and clone again\n"
               "   [C-g] to abort ")
              '(?u ?r ?t))
        (?u (magit-submodule--restore-worktree (expand-file-name path) gitdir))
        (?r (rename-file gitdir (concat gitdir "-"
                                        (format-time-string "%F-%T"))))
        (?t (delete-directory gitdir t t))))))