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

[PATCH (resend)] Let core.excludesfile default to ~/.gitexcludes.

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Nov 26, 2009, 10:35 UTC
Message-ID
<1259231726-5218-1-git-send-email-Matthieu.Moy@imag.fr>
In-Reply-To
<1258840832-22130-1-git-send-email-Matthieu.Moy@imag.fr>

Most users will set it to ~/.gitsomething. ~/.gitignore would conflict with per-directory ignore file if ~/ is managed by Git, so ~/.gitexcludes is a sane default.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
(just resending since the patch seems to have got lost in the process)
 Documentation/config.txt |    1 +
 dir.c                    |    9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 7ff2d1d..9fc527c 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -408,6 +408,7 @@ core.excludesfile::
 	of files which are not meant to be tracked.  "{tilde}/" is expanded
 	to the value of `$HOME` and "{tilde}user/" to the specified user's
 	home directory.  See linkgit:gitignore[5].
+	Default: ~/.gitexcludes.
 
 core.editor::
 	Commands such as `commit` and `tag` that lets you edit
diff --git a/dir.c b/dir.c
index 3a8d3e6..a6a6291 100644
--- a/dir.c
+++ b/dir.c
@@ -944,9 +944,16 @@ void setup_standard_excludes(struct dir_struct *dir)
 
 	dir->exclude_per_dir = ".gitignore";
 	path = git_path("info/exclude");
+	if (!excludes_file) {
+		const char *home = getenv("HOME");
+		char *user_gitignore = malloc(strlen(home) + strlen("/.gitexcludes") + 1);
+		strcpy(user_gitignore, home);
+		strcat(user_gitignore, "/.gitexcludes");
+		excludes_file = user_gitignore;
+	}
 	if (!access(path, R_OK))
 		add_excludes_from_file(dir, path);
-	if (excludes_file && !access(excludes_file, R_OK))
+	if (!access(excludes_file, R_OK))
 		add_excludes_from_file(dir, excludes_file);
 }
 
-- 
1.6.5.3.435.g5f2e3.dirty
Previous: Matthieu MoyNext: Michael J Gruber
Message 5 of 17 in “let core.excludesfile default to ~/.gitignore.”
  1. let core.excludesfile default to ~/.gitignore.Matthieu Moy, Nov 20, 2009
  2. Stefan NaeweNov 20, 2009
  3. David AguilarNov 20, 2009
  4. Let core.excludesfile default to ~/.gitexcludes.Matthieu Moy, Nov 21, 2009
  5. Let core.excludesfile default to ~/.gitexcludes.Matthieu Moy, Nov 26, 2009
  6. Michael J GruberNov 26, 2009
  7. Paolo BonziniNov 26, 2009
  8. Michael J GruberNov 26, 2009
  9. Bert WesargNov 26, 2009
  10. Michael J GruberNov 26, 2009
  11. David AguilarNov 26, 2009
  12. Junio C HamanoNov 26, 2009
  13. Nanako ShiraishiDec 30, 2009
  14. Matthieu MoyDec 30, 2009
  15. Junio C HamanoDec 30, 2009
  16. User-wide Git config directory (was Re: [PATCH v2] Let core.excludesfile default to ~/.gitexcludes.)Matthieu Moy, Jan 2, 2010
  17. Junio C HamanoNov 20, 2009

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.