diff options
| -rw-r--r-- | lisp/magit-gitignore.el | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/lisp/magit-gitignore.el b/lisp/magit-gitignore.el index 141b2ab..71f3d38 100644 --- a/lisp/magit-gitignore.el +++ b/lisp/magit-gitignore.el @@ -108,27 +108,10 @@ Rules that are defined in that file affect all local repositories." (magit-refresh))) (defun magit-gitignore-read-pattern () - (let* ((default (magit-current-file)) - (base (car magit-buffer-diff-files)) + (let* ((base (car magit-buffer-diff-files)) (base (and base (file-directory-p base) base)) - (choices - (delete-dups - (mapcan - (lambda (file) - (cons (concat "/" file) - (and$ (file-name-extension file) - (list (concat "/" (file-name-directory file) "*." $) - (concat "*." $))))) - (sort (nconc - (magit-untracked-files nil base) - ;; The untracked section of the status buffer lists - ;; directories containing only untracked files. - ;; Add those as candidates. - (seq-filter #'directory-name-p - (magit-list-files - "--other" "--exclude-standard" "--directory" - "--no-empty-directory" "--" base))) - #'string-lessp))))) + (choices (magit--gitignore-patterns base)) + (default (magit-current-file))) (when default (setq default (concat "/" default)) (unless (member default choices) @@ -138,6 +121,25 @@ Rules that are defined in that file affect all local repositories." (magit-completing-read "File or pattern to ignore" choices nil 'any nil nil default))) +(defun magit--gitignore-patterns (&optional directory) + (delete-dups + (mapcan + (lambda (file) + (cons (concat "/" file) + (and$ (file-name-extension file) + (list (concat "/" (file-name-directory file) "*." $) + (concat "*." $))))) + (sort (nconc + (magit-untracked-files nil directory) + ;; The untracked section of the status buffer lists + ;; directories containing only untracked files. + ;; Add those as candidates. + (seq-filter #'directory-name-p + (magit-list-files + "--other" "--exclude-standard" "--directory" + "--no-empty-directory" "--" directory))) + #'string-lessp)))) + ;;; Skip Worktree Commands ;;;###autoload |
