Web lists-archives.com

[PATCH] git.el: handle default excludesfile properly

The previous version only looked at core.excludesfile for locating the
excludesfile.  So, when core.excludesfile was not defined, it did not
use the possible default locations.

The current version uses either $XDG_CONFIG_HOME/git/ignore or
$HOME/.config/git/ignore for the default excludesfile location
depending on whether XDG_CONFIG_HOME is defined or not.  As per the
documentation of gitignore.

Signed-off-by: Dorab Patel <dorabpatel@xxxxxxxxx>
 contrib/emacs/git.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 97919f2d7..16c6b4c05 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -757,8 +757,12 @@ Return the list of files that haven't been handled."
 (defun git-get-exclude-files ()
   "Get the list of exclude files to pass to git-ls-files."
-  (let (files
-        (config (git-config "core.excludesfile")))
+  (let* (files
+	 (defaultconfig (if (getenv "XDG_CONFIG_HOME")
+			    (concat (file-name-as-directory (getenv "XDG_CONFIG_HOME")) "git/ignore")
+			  (concat (file-name-as-directory (getenv "HOME")) ".config/git/ignore")))
+	 (coreexcludes (git-config "core.excludesfile"))
+	 (config (if coreexcludes coreexcludes defaultconfig)))
     (when (file-readable-p ".git/info/exclude")
       (push ".git/info/exclude" files))
     (when (and config (file-readable-p config))