git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git.el: handle default excludesfile properly

From
DPDorab Patel <dorabpatel@gmail.com>
Date
Mar 3, 2018, 03:48 UTC
Message-ID
<20180303034803.21589-1-dorabpatel@gmail.com>

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@gmail.com>
---
 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))
-- 
2.16.2
Next: Eric Sunshine
Message 1 of 19 in “git.el: handle default excludesfile properly”
  1. git.el: handle default excludesfile properlyDorab Patel, Mar 3, 2018
  2. Eric SunshineMar 3, 2018
  3. Dorab PatelMar 4, 2018
  4. Eric SunshineMar 4, 2018
  5. Dorab PatelMar 4, 2018
  6. Eric SunshineMar 4, 2018
  7. Junio C HamanoMar 5, 2018
  8. Alexandre JulliardMar 6, 2018
  9. Dorab PatelMar 7, 2018
  10. Ævar Arnfjörð BjarmasonMar 8, 2018
  11. git{,-blame}.el: remove old bitrotting Emacs codeÆvar Arnfjörð Bjarmason, Mar 8, 2018
  12. Junio C HamanoMar 8, 2018
  13. git{,-blame}.el: remove old bitrotting Emacs codeÆvar Arnfjörð Bjarmason, Mar 10, 2018
  14. Martin ÅgrenMar 10, 2018
  15. Junio C HamanoMar 13, 2018
  16. Ævar Arnfjörð BjarmasonMar 13, 2018
  17. Junio C HamanoMar 13, 2018
  18. Kyle MeyerMar 8, 2018
  19. git.el: handle default excludesfile properlyDorab Patel, Mar 6, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.