Skip to content

Commit 274e13e

Browse files
julliardgitster
authored andcommitted
git.el: Take into account the core.excludesfile config option.
Also don't require .git/info/exclude to exist in order to list unknown files. Signed-off-by: Alexandre Julliard <[email protected]> Acked-by: Karl Hasselström <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 61988f1 commit 274e13e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

contrib/emacs/git.el

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,16 @@ Return the list of files that haven't been handled."
589589
(when node (push (ewoc-data node) unmerged-files))))
590590
(git-set-files-state unmerged-files 'unmerged))))
591591

592+
(defun git-get-exclude-files ()
593+
"Get the list of exclude files to pass to git-ls-files."
594+
(let (files
595+
(config (git-config "core.excludesfile")))
596+
(when (file-readable-p ".git/info/exclude")
597+
(push ".git/info/exclude" files))
598+
(when (and config (file-readable-p config))
599+
(push config files))
600+
files))
601+
592602
(defun git-update-status-files (files &optional default-state)
593603
"Update the status of FILES from the index."
594604
(unless git-status (error "Not in git-status buffer."))
@@ -598,11 +608,11 @@ Return the list of files that haven't been handled."
598608
(git-run-ls-files status files 'added "-c")
599609
(git-run-diff-index status files))))
600610
(git-run-ls-unmerged status files)
601-
(when (and (or (not files) remaining-files)
602-
(file-readable-p ".git/info/exclude"))
603-
(setq remaining-files (git-run-ls-files status remaining-files
604-
'unknown "-o" "--exclude-from=.git/info/exclude"
605-
(concat "--exclude-per-directory=" git-per-dir-ignore-file))))
611+
(when (or (not files) remaining-files)
612+
(let ((exclude-files (git-get-exclude-files)))
613+
(setq remaining-files (apply #'git-run-ls-files status remaining-files 'unknown "-o"
614+
(concat "--exclude-per-directory=" git-per-dir-ignore-file)
615+
(mapcar (lambda (f) (concat "--exclude-from=" f)) exclude-files)))))
606616
; mark remaining files with the default state (or remove them if nil)
607617
(when remaining-files
608618
(if default-state

0 commit comments

Comments
 (0)