git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] let core.excludesfile default to ~/.gitignore.
@ 2009-11-20 13:23 Matthieu Moy
  2009-11-20 14:30 ` Stefan Naewe
  2009-11-20 22:49 ` [PATCH] let core.excludesfile default to ~/.gitignore Junio C Hamano
  0 siblings, 2 replies; 17+ messages in thread
From: Matthieu Moy @ 2009-11-20 13:23 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy

It seems this is the value most users set, so let's make it the default.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
A funny experiment:

http://www.google.com/search?q=core.excludesfile+-%22~/.gitignore%22
Results 1 - 10 of about 3,890 for core.excludesfile -"~/.gitignore"

http://www.google.com/search?q=core.excludesfile+%22~/.gitignore%22
Results 1 - 10 of about 7,990 for core.excludesfile "~/.gitignore"

So, most of the time someone mentions core.excludesfile on the web,
~/.gitignore is mentionned right after.


I'd have expected a place near config.c to set the default value for
any config variable, but I can't find such thing, so I guess the
caller is the one that should set the default, which is what I do in
the patch.

 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 39d1226..0c55e52 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -384,6 +384,7 @@ core.excludesfile::
 	of files which are not meant to be tracked.  "~/" is expanded
 	to the value of `$HOME` and "~user/" to the specified user's
 	home directory.  See linkgit:gitignore[5].
+	Default: ~/.gitignore.
 
 core.editor::
 	Commands such as `commit` and `tag` that lets you edit
diff --git a/dir.c b/dir.c
index d0999ba..dcea6ad 100644
--- a/dir.c
+++ b/dir.c
@@ -914,9 +914,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("/.gitignore") + 1);
+		strcpy(user_gitignore, home);
+		strcat(user_gitignore, "/.gitignore");
+		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.2.152.gbbe9e

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2010-01-02 12:08 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-20 13:23 [PATCH] let core.excludesfile default to ~/.gitignore Matthieu Moy
2009-11-20 14:30 ` Stefan Naewe
2009-11-20 18:50   ` David Aguilar
2009-11-21 22:00   ` [PATCH v2] Let core.excludesfile default to ~/.gitexcludes Matthieu Moy
2009-11-26 10:35     ` [PATCH (resend)] " Matthieu Moy
2009-11-26 12:00       ` Michael J Gruber
2009-11-26 12:49         ` Paolo Bonzini
2009-11-26 13:27           ` Michael J Gruber
2009-11-26 13:01         ` Bert Wesarg
2009-11-26 13:39           ` Michael J Gruber
2009-11-26 20:07             ` David Aguilar
2009-11-26 18:18         ` Junio C Hamano
2009-12-30 13:41     ` [PATCH v2] " Nanako Shiraishi
2009-12-30 14:31       ` Matthieu Moy
2009-12-30 19:49         ` Junio C Hamano
2010-01-02 12:05           ` User-wide Git config directory (was Re: [PATCH v2] Let core.excludesfile default to ~/.gitexcludes.) Matthieu Moy
2009-11-20 22:49 ` [PATCH] let core.excludesfile default to ~/.gitignore Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).