All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <junkio@cox.net>
Cc: hanwen@xs4all.nl,
	Peter Baumann <siprbaum@stud.informatik.uni-erlangen.de>,
	Andy Parkins <andyparkins@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] config: read system-wide defaults from /etc/gitconfig
Date: Wed, 14 Feb 2007 20:25:52 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.63.0702142015150.22628@wbgn013.biozentrum.uni-wuerzburg.de> (raw)
In-Reply-To: <7vr6sso8w8.fsf@assigned-by-dhcp.cox.net>

Hi,

On Wed, 14 Feb 2007, Junio C Hamano wrote:

> Han-Wen Nienhuys <hanwen@xs4all.nl> writes:
> 
> > Johannes Schindelin escreveu:
> >> The settings in /etc/gitconfig can be overridden in ~/.gitconfig,
> >> which in turn can be overridden in .git/config.
> >
> >> +#define ETC_GITCONFIG "/etc/gitconfig"
> >
> >> +		if (!access(ETC_GITCONFIG, R_OK))
> >> +			ret += git_config_from_file(fn, ETC_GITCONFIG);
> >
> > this is a stupid idea.  
> 
> Stupid probably is too strong a word, but I think I'd agree we
> should default it to $(prefix)/etc and have distros override it
> in the Makefile.

Fair enough. And my patch was not really complete. Please amend to spare 
me eternal shame:
--
[BROWN PAPERBAG PATCH ON TOP OF OTHER PATCH] 

It is $prefix/etc/gitconfig now, and works also if you do not
`git config -l`. D'oh.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

 Makefile         |    5 ++++-
 builtin-config.c |    7 ++++++-
 cache.h          |    1 -
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 6f05abb..617908c 100644
--- a/Makefile
+++ b/Makefile
@@ -128,6 +128,7 @@ prefix = $(HOME)
 bindir = $(prefix)/bin
 gitexecdir = $(bindir)
 template_dir = $(prefix)/share/git-core/templates/
+ETC_GITCONFIG = $(prefix)/etc/gitconfig
 # DESTDIR=
 
 # default configuration for gitweb
@@ -591,6 +592,7 @@ endif
 # Shell quote (do not use $(call) to accommodate ancient setups);
 
 SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
+ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
 
 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
 bindir_SQ = $(subst ','\'',$(bindir))
@@ -603,7 +605,8 @@ PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
 
 LIBS = $(GITLIBS) $(EXTLIBS)
 
-BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
+BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
+	-DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $(COMPAT_CFLAGS)
 LIB_OBJS += $(COMPAT_OBJS)
 
 ALL_CFLAGS += $(BASIC_CFLAGS)
diff --git a/builtin-config.c b/builtin-config.c
index 0f9051d..34470c4 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -64,7 +64,7 @@ static int get_value(const char* key_, const char* regex_)
 	int ret = -1;
 	char *tl;
 	char *global = NULL, *repo_config = NULL;
-	const char *local;
+	const char *system_wide = NULL, *local;
 
 	local = getenv(CONFIG_ENVIRONMENT);
 	if (!local) {
@@ -74,6 +74,7 @@ static int get_value(const char* key_, const char* regex_)
 			local = repo_config = xstrdup(git_path("config"));
 		if (home)
 			global = xstrdup(mkpath("%s/.gitconfig", home));
+		system_wide = ETC_GITCONFIG;
 	}
 
 	key = xstrdup(key_);
@@ -103,11 +104,15 @@ static int get_value(const char* key_, const char* regex_)
 		}
 	}
 
+	if (do_all && system_wide)
+		git_config_from_file(show_config, system_wide);
 	if (do_all && global)
 		git_config_from_file(show_config, global);
 	git_config_from_file(show_config, local);
 	if (!do_all && !seen && global)
 		git_config_from_file(show_config, global);
+	if (!do_all && !seen && system_wide)
+		git_config_from_file(show_config, system_wide);
 
 	free(key);
 	if (regexp) {
diff --git a/cache.h b/cache.h
index e316f66..44941c0 100644
--- a/cache.h
+++ b/cache.h
@@ -123,7 +123,6 @@ extern int cache_errno;
 #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
 #define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
 #define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
-#define ETC_GITCONFIG "/etc/gitconfig"
 #define CONFIG_ENVIRONMENT "GIT_CONFIG"
 #define CONFIG_LOCAL_ENVIRONMENT "GIT_CONFIG_LOCAL"
 #define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"

  reply	other threads:[~2007-02-14 19:25 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-14  9:09 /etc/gitconfig Andy Parkins
2007-02-14 10:30 ` /etc/gitconfig Peter Baumann
2007-02-14 11:48   ` [PATCH] config: read system-wide defaults from /etc/gitconfig Johannes Schindelin
2007-02-14 16:30     ` Junio C Hamano
2007-02-14 17:45       ` Johannes Schindelin
2007-02-14 17:57         ` Junio C Hamano
2007-02-14 18:02           ` Johannes Schindelin
2007-02-14 18:12             ` Junio C Hamano
2007-02-14 18:19               ` Nicolas Pitre
2007-02-14 19:06                 ` Junio C Hamano
2007-02-15 10:19       ` Andy Parkins
2007-02-15 11:26         ` Junio C Hamano
     [not found]         ` <20070215113557.GB2282@steel.home>
     [not found]           ` <20070216143952.GA2478@steel.home>
2007-02-16 14:42             ` [PATCH] Allow config files to be included Alex Riesen
2007-02-16 14:45               ` Alex Riesen
2007-02-14 18:10     ` [PATCH] config: read system-wide defaults from /etc/gitconfig Han-Wen Nienhuys
2007-02-14 19:07       ` Junio C Hamano
2007-02-14 19:25         ` Johannes Schindelin [this message]
2007-02-14 19:43           ` Junio C Hamano
2007-02-14 19:54             ` Johannes Schindelin
2007-02-14 22:39               ` Johannes Schindelin
2007-02-15  5:27               ` Junio C Hamano
2007-02-15  8:46                 ` Junio C Hamano
2007-02-15  9:59                   ` Eric Wong
2007-02-15 10:03                     ` Eric Wong
2007-02-15 10:36                     ` Junio C Hamano
2007-02-15 10:43                 ` Johannes Schindelin
2007-02-15 11:25                   ` Junio C Hamano
2007-02-15 12:05                     ` Johannes Schindelin
2007-02-19  1:47                     ` Jakub Narebski
2007-02-14 10:40 ` /etc/gitconfig Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.63.0702142015150.22628@wbgn013.biozentrum.uni-wuerzburg.de \
    --to=johannes.schindelin@gmx.de \
    --cc=andyparkins@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=hanwen@xs4all.nl \
    --cc=junkio@cox.net \
    --cc=siprbaum@stud.informatik.uni-erlangen.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.