{"thread":{"id":"6813","subject":"/etc/gitconfig","startedAt":"2007-02-14T09:09:26Z","lastAt":"2007-02-19T01:47:00Z","messageCount":30,"participants":["Andy Parkins","Peter Baumann","Uwe Kleine-König","Johannes Schindelin","Junio C Hamano","Han-Wen Nienhuys","Nicolas Pitre","Eric Wong","Alex Riesen","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"34506","messageId":"200702140909.28369.andyparkins@gmail.com","threadId":"6813","inReplyTo":null,"subject":"/etc/gitconfig","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-02-14T09:09:26Z","receivedAt":"2007-02-14T09:09:26Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"Hello\n\nWith the release of 1.5.0 I added legacyheaders=false and \nusedelatbaseoffset=true to my repositories.\n\nWhile doing that though, it felt wrong to be editing every single config.  Is \nthere a justification for having three config files?\n\n /etc/gitconfig\n $HOME/.gitconfig\n $GIT_DIR/config\n\nWith /etc/gitconfig coming in at lowest priority?\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIEE\nandyparkins@gmail.com\n"},{"id":"34511","messageId":"slrnet5p5h.s9h.siprbaum@xp.machine.xx","threadId":"6813","inReplyTo":"200702140909.28369.andyparkins@gmail.com","subject":"Re: /etc/gitconfig","fromName":"Peter Baumann","fromEmail":"siprbaum@stud.informatik.uni-erlangen.de","sentAt":"2007-02-14T10:30:09Z","receivedAt":"2007-02-14T10:30:09Z","isPatch":false,"sender":{"key":"waste.manager@gmx.de","avatar":null},"body":"Andy Parkins <andyparkins@gmail.com> schrieb:\n> Hello\n>\n> With the release of 1.5.0 I added legacyheaders=false and \n> usedelatbaseoffset=true to my repositories.\n>\n> While doing that though, it felt wrong to be editing every single config.  Is \n> there a justification for having three config files?\n>\n>  /etc/gitconfig\n>  $HOME/.gitconfig\n>  $GIT_DIR/config\n>\n> With /etc/gitconfig coming in at lowest priority?\n>\n> Andy\n\nI would like this, too. This would allow me to set e.g.\n\"diff.color = auto\" for everyone one a machine. We use git there to only\nmanage some config files and several simple perl scripts. As it is\nmostly myself who does the editing, ~/.gitconfig works for *ME*.\n\nBut I'd like to set this globally so that my colluagues which don't have\nmuch clue about git don't need to bother about config settings. And yes,\nediting every single repo doesn't seem like an elegant solution. \n\n-Peter\n"},{"id":"34512","messageId":"20070214104052.GA9047@informatik.uni-freiburg.de","threadId":"6813","inReplyTo":"200702140909.28369.andyparkins@gmail.com","subject":"Re: /etc/gitconfig","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-02-14T10:40:52Z","receivedAt":"2007-02-14T10:40:52Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Andy Parkins wrote:\n> With the release of 1.5.0 I added legacyheaders=false and \n> usedelatbaseoffset=true to my repositories.\n> \n> While doing that though, it felt wrong to be editing every single config.  Is \n> there a justification for having three config files?\n> \n>  /etc/gitconfig\n>  $HOME/.gitconfig\n>  $GIT_DIR/config\n> \n> With /etc/gitconfig coming in at lowest priority?\nI didn't try it, but maybe you could place your desired config to\n/usr/share/git-core/templates/config and then at least newly created\nrepos get it?\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\n$ dc -e \"5735816763073014741799356604682P\"\n"},{"id":"34520","messageId":"Pine.LNX.4.63.0702141246160.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6813","inReplyTo":"slrnet5p5h.s9h.siprbaum@xp.machine.xx","subject":"[PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-14T11:48:14Z","receivedAt":"2007-02-14T11:48:14Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThe settings in /etc/gitconfig can be overridden in ~/.gitconfig,\nwhich in turn can be overridden in .git/config.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n\n\tOn Wed, 14 Feb 2007, Peter Baumann wrote:\n\n\t> Andy Parkins <andyparkins@gmail.com> schrieb:\n\t> >\n\t> > With the release of 1.5.0 I added legacyheaders=false and\n\t> > usedelatbaseoffset=true to my repositories.\n\t> >\n\t> > While doing that though, it felt wrong to be editing every \n\t> > single config.  Is there a justification for having three \n\t> > config files?\n\t> >\n\t> >  /etc/gitconfig\n\t> >  $HOME/.gitconfig\n\t> >  $GIT_DIR/config\n\t> >\n\t> > With /etc/gitconfig coming in at lowest priority?\n\t> \n\t> I would like this, too. This would allow me to set e.g.\n\t> \"diff.color = auto\" for everyone one a machine. We use git there \n\t> to only manage some config files and several simple perl \n\t> scripts. As it is mostly myself who does the editing, \n\t> ~/.gitconfig works for *ME*.\n\t> \n\t> But I'd like to set this globally so that my colluagues which \n\t> don't have much clue about git don't need to bother about config \n\t> settings. And yes, editing every single repo doesn't seem like \n\t> an elegant solution.\n\n\tVoilà.\n\n Documentation/config.txt |    3 ++-\n cache.h                  |    1 +\n config.c                 |    2 ++\n 3 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 3865535..1dd90d8 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -5,7 +5,8 @@ The git configuration file contains a number of variables that affect\n the git command's behavior. `.git/config` file for each repository\n is used to store the information for that repository, and\n `$HOME/.gitconfig` is used to store per user information to give\n-fallback values for `.git/config` file.\n+fallback values for `.git/config` file. The file `/etc/gitconfig`\n+can be used to store system-wide defaults.\n \n They can be used by both the git plumbing\n and the porcelains. The variables are divided into sections, where\ndiff --git a/cache.h b/cache.h\nindex 44941c0..e316f66 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -123,6 +123,7 @@ extern int cache_errno;\n #define INDEX_ENVIRONMENT \"GIT_INDEX_FILE\"\n #define GRAFT_ENVIRONMENT \"GIT_GRAFT_FILE\"\n #define TEMPLATE_DIR_ENVIRONMENT \"GIT_TEMPLATE_DIR\"\n+#define ETC_GITCONFIG \"/etc/gitconfig\"\n #define CONFIG_ENVIRONMENT \"GIT_CONFIG\"\n #define CONFIG_LOCAL_ENVIRONMENT \"GIT_CONFIG_LOCAL\"\n #define EXEC_PATH_ENVIRONMENT \"GIT_EXEC_PATH\"\ndiff --git a/config.c b/config.c\nindex d821071..b0c0948 100644\n--- a/config.c\n+++ b/config.c\n@@ -383,6 +383,8 @@ int git_config(config_fn_t fn)\n \t * config file otherwise. */\n \tfilename = getenv(CONFIG_ENVIRONMENT);\n \tif (!filename) {\n+\t\tif (!access(ETC_GITCONFIG, R_OK))\n+\t\t\tret += git_config_from_file(fn, ETC_GITCONFIG);\n \t\thome = getenv(\"HOME\");\n \t\tfilename = getenv(CONFIG_LOCAL_ENVIRONMENT);\n \t\tif (!filename)\n-- \n1.5.0.rc4.2447.g06287-dirty\n"},{"id":"34552","messageId":"7vfy98snus.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"Pine.LNX.4.63.0702141246160.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T16:30:51Z","receivedAt":"2007-02-14T16:30:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> The settings in /etc/gitconfig can be overridden in ~/.gitconfig,\n> which in turn can be overridden in .git/config.\n>\n> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> ---\n> ...\n> \tVoilà.\n\nI knew this can be done, and you are capable of doing this, but\nI was wondering if it is a good thing to do in the first place.\n\nSite-wide configuration for options that are potentially\ncompatibility-breaking is a bad idea on a multi-user machines,\nand it was certainly the case back when our machines hosted many\ndiverse set of people.\n\nBut these days many machines are practically single-user and\nmany more are owned by a single group/project that share the\nsame policy.  So in such a setting, /etc/gitconfig might not be\ntoo bad.  \n"},{"id":"34583","messageId":"Pine.LNX.4.63.0702141843190.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6813","inReplyTo":"7vfy98snus.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-14T17:45:38Z","receivedAt":"2007-02-14T17:45:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Feb 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > The settings in /etc/gitconfig can be overridden in ~/.gitconfig,\n> > which in turn can be overridden in .git/config.\n> >\n> > Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> > ---\n> > ...\n> > \tVoilà.\n> \n> I knew this can be done, and you are capable of doing this, but I was \n> wondering if it is a good thing to do in the first place.\n> \n> Site-wide configuration for options that are potentially \n> compatibility-breaking is a bad idea on a multi-user machines, and it \n> was certainly the case back when our machines hosted many diverse set of \n> people.\n\nThat is why /etc is only writable by the administrator. And contrary to \nthe Microsoft-infected world, Unix and Linux administrators are expected \nto have real know how. If they don't care about breaking things or not, \nthey'll find other ways to screw you.\n\n> But these days many machines are practically single-user and many more \n> are owned by a single group/project that share the same policy.  So in \n> such a setting, /etc/gitconfig might not be too bad.\n\nWell, I don't use it myself (other than testing that the patch does what \nit says). Let the list decide?\n\nCiao,\nDscho\n"},{"id":"34589","messageId":"7vlkj0pqp5.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"Pine.LNX.4.63.0702141843190.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T17:57:42Z","receivedAt":"2007-02-14T17:57:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Well, I don't use it myself (other than testing that the patch does what \n> it says). Let the list decide?\n\nI am slightly worried about stupid distros screwing people over\nby shipping with a bad default config in /etc, which would make\ndiagnosing their problems harder without knowing what they have\nthere.  But other than that I do not have a problem with it.\n"},{"id":"34592","messageId":"Pine.LNX.4.63.0702141901250.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6813","inReplyTo":"7vlkj0pqp5.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-14T18:02:01Z","receivedAt":"2007-02-14T18:02:01Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Feb 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > Well, I don't use it myself (other than testing that the patch does what \n> > it says). Let the list decide?\n> \n> I am slightly worried about stupid distros screwing people over\n> by shipping with a bad default config in /etc, which would make\n> diagnosing their problems harder without knowing what they have\n> there.  But other than that I do not have a problem with it.\n\nThey can do that already by shipping with a bad default /etc/skel/ \ndirectory.\n\nCiao,\nDscho\n"},{"id":"34595","messageId":"45D35092.8040901@xs4all.nl","threadId":"6813","inReplyTo":"Pine.LNX.4.63.0702141246160.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Han-Wen Nienhuys","fromEmail":"hanwen@xs4all.nl","sentAt":"2007-02-14T18:10:26Z","receivedAt":"2007-02-14T18:10:26Z","isPatch":true,"sender":{"key":"hanwen@google.com","avatar":"https://avatars.githubusercontent.com/u/31547?v=4"},"body":"Johannes Schindelin escreveu:\n> The settings in /etc/gitconfig can be overridden in ~/.gitconfig,\n> which in turn can be overridden in .git/config.\n\n> +#define ETC_GITCONFIG \"/etc/gitconfig\"\n\n> +\t\tif (!access(ETC_GITCONFIG, R_OK))\n> +\t\t\tret += git_config_from_file(fn, ETC_GITCONFIG);\n\nthis is a stupid idea.  \n\nThis should use the path given as the --sysconfdir argument to configure. \nIf the configure result is not available, it should default to $prefix/etc/ \n\nIt should be possible to install private copy of Git without being affected\nby system wide defaults.\n\n\n-- \n Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen\n"},{"id":"34596","messageId":"7vd54cpq0v.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"Pine.LNX.4.63.0702141901250.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T18:12:16Z","receivedAt":"2007-02-14T18:12:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi,\n>\n> On Wed, 14 Feb 2007, Junio C Hamano wrote:\n>\n>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n>> \n>> > Well, I don't use it myself (other than testing that the patch does what \n>> > it says). Let the list decide?\n>> \n>> I am slightly worried about stupid distros screwing people over\n>> by shipping with a bad default config in /etc, which would make\n>> diagnosing their problems harder without knowing what they have\n>> there.  But other than that I do not have a problem with it.\n>\n> They can do that already by shipping with a bad default /etc/skel/ \n> directory.\n\nThat's slightly different.  I can ask \"Do you have anything\nspecial in your $HOME/.gitconfig?\"  Now I have to ask two\nquestions (and I would not know if a particular distro compiled\ngit to use /etc/git/default.config or /etc/gitconfig or whatever).\n"},{"id":"34599","messageId":"Pine.LNX.4.64.0702141318060.1757@xanadu.home","threadId":"6813","inReplyTo":"7vd54cpq0v.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-02-14T18:19:34Z","receivedAt":"2007-02-14T18:19:34Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Wed, 14 Feb 2007, Junio C Hamano wrote:\n\n> That's slightly different.  I can ask \"Do you have anything\n> special in your $HOME/.gitconfig?\"  Now I have to ask two\n> questions (and I would not know if a particular distro compiled\n> git to use /etc/git/default.config or /etc/gitconfig or whatever).\n\nWhy not simplifying the question to only:\n\n\tgit config -l\n\nthen?\n\n\nNicolas\n"},{"id":"34605","messageId":"7vvei4o8y2.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"Pine.LNX.4.64.0702141318060.1757@xanadu.home","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T19:06:29Z","receivedAt":"2007-02-14T19:06:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nicolas Pitre <nico@cam.org> writes:\n\n> Why not simplifying the question to only:\n>\n> \tgit config -l\n>\n> then?\n\nFair enough.\n"},{"id":"34606","messageId":"7vr6sso8w8.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"45D35092.8040901@xs4all.nl","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T19:07:35Z","receivedAt":"2007-02-14T19:07:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Han-Wen Nienhuys <hanwen@xs4all.nl> writes:\n\n> Johannes Schindelin escreveu:\n>> The settings in /etc/gitconfig can be overridden in ~/.gitconfig,\n>> which in turn can be overridden in .git/config.\n>\n>> +#define ETC_GITCONFIG \"/etc/gitconfig\"\n>\n>> +\t\tif (!access(ETC_GITCONFIG, R_OK))\n>> +\t\t\tret += git_config_from_file(fn, ETC_GITCONFIG);\n>\n> this is a stupid idea.  \n\nStupid probably is too strong a word, but I think I'd agree we\nshould default it to $(prefix)/etc and have distros override it\nin the Makefile.\n"},{"id":"34607","messageId":"Pine.LNX.4.63.0702142015150.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6813","inReplyTo":"7vr6sso8w8.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-14T19:25:52Z","receivedAt":"2007-02-14T19:25:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Feb 2007, Junio C Hamano wrote:\n\n> Han-Wen Nienhuys <hanwen@xs4all.nl> writes:\n> \n> > Johannes Schindelin escreveu:\n> >> The settings in /etc/gitconfig can be overridden in ~/.gitconfig,\n> >> which in turn can be overridden in .git/config.\n> >\n> >> +#define ETC_GITCONFIG \"/etc/gitconfig\"\n> >\n> >> +\t\tif (!access(ETC_GITCONFIG, R_OK))\n> >> +\t\t\tret += git_config_from_file(fn, ETC_GITCONFIG);\n> >\n> > this is a stupid idea.  \n> \n> Stupid probably is too strong a word, but I think I'd agree we\n> should default it to $(prefix)/etc and have distros override it\n> in the Makefile.\n\nFair enough. And my patch was not really complete. Please amend to spare \nme eternal shame:\n--\n[BROWN PAPERBAG PATCH ON TOP OF OTHER PATCH] \n\nIt is $prefix/etc/gitconfig now, and works also if you do not\n`git config -l`. D'oh.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n Makefile         |    5 ++++-\n builtin-config.c |    7 ++++++-\n cache.h          |    1 -\n 3 files changed, 10 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 6f05abb..617908c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -128,6 +128,7 @@ prefix = $(HOME)\n bindir = $(prefix)/bin\n gitexecdir = $(bindir)\n template_dir = $(prefix)/share/git-core/templates/\n+ETC_GITCONFIG = $(prefix)/etc/gitconfig\n # DESTDIR=\n \n # default configuration for gitweb\n@@ -591,6 +592,7 @@ endif\n # Shell quote (do not use $(call) to accommodate ancient setups);\n \n SHA1_HEADER_SQ = $(subst ','\\'',$(SHA1_HEADER))\n+ETC_GITCONFIG_SQ = $(subst ','\\'',$(ETC_GITCONFIG))\n \n DESTDIR_SQ = $(subst ','\\'',$(DESTDIR))\n bindir_SQ = $(subst ','\\'',$(bindir))\n@@ -603,7 +605,8 @@ PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n \n LIBS = $(GITLIBS) $(EXTLIBS)\n \n-BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)\n+BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \\\n+\t-DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"' $(COMPAT_CFLAGS)\n LIB_OBJS += $(COMPAT_OBJS)\n \n ALL_CFLAGS += $(BASIC_CFLAGS)\ndiff --git a/builtin-config.c b/builtin-config.c\nindex 0f9051d..34470c4 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -64,7 +64,7 @@ static int get_value(const char* key_, const char* regex_)\n \tint ret = -1;\n \tchar *tl;\n \tchar *global = NULL, *repo_config = NULL;\n-\tconst char *local;\n+\tconst char *system_wide = NULL, *local;\n \n \tlocal = getenv(CONFIG_ENVIRONMENT);\n \tif (!local) {\n@@ -74,6 +74,7 @@ static int get_value(const char* key_, const char* regex_)\n \t\t\tlocal = repo_config = xstrdup(git_path(\"config\"));\n \t\tif (home)\n \t\t\tglobal = xstrdup(mkpath(\"%s/.gitconfig\", home));\n+\t\tsystem_wide = ETC_GITCONFIG;\n \t}\n \n \tkey = xstrdup(key_);\n@@ -103,11 +104,15 @@ static int get_value(const char* key_, const char* regex_)\n \t\t}\n \t}\n \n+\tif (do_all && system_wide)\n+\t\tgit_config_from_file(show_config, system_wide);\n \tif (do_all && global)\n \t\tgit_config_from_file(show_config, global);\n \tgit_config_from_file(show_config, local);\n \tif (!do_all && !seen && global)\n \t\tgit_config_from_file(show_config, global);\n+\tif (!do_all && !seen && system_wide)\n+\t\tgit_config_from_file(show_config, system_wide);\n \n \tfree(key);\n \tif (regexp) {\ndiff --git a/cache.h b/cache.h\nindex e316f66..44941c0 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -123,7 +123,6 @@ extern int cache_errno;\n #define INDEX_ENVIRONMENT \"GIT_INDEX_FILE\"\n #define GRAFT_ENVIRONMENT \"GIT_GRAFT_FILE\"\n #define TEMPLATE_DIR_ENVIRONMENT \"GIT_TEMPLATE_DIR\"\n-#define ETC_GITCONFIG \"/etc/gitconfig\"\n #define CONFIG_ENVIRONMENT \"GIT_CONFIG\"\n #define CONFIG_LOCAL_ENVIRONMENT \"GIT_CONFIG_LOCAL\"\n #define EXEC_PATH_ENVIRONMENT \"GIT_EXEC_PATH\"\n"},{"id":"34613","messageId":"7vfy98o78i.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"Pine.LNX.4.63.0702142015150.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-14T19:43:25Z","receivedAt":"2007-02-14T19:43:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> Stupid probably is too strong a word, but I think I'd agree we\n>> should default it to $(prefix)/etc and have distros override it\n>> in the Makefile.\n>\n> Fair enough. And my patch was not really complete. Please amend to spare \n> me eternal shame:\n> --\n> [BROWN PAPERBAG PATCH ON TOP OF OTHER PATCH] \n>\n> It is $prefix/etc/gitconfig now, and works also if you do not\n> `git config -l`. D'oh.\n\nHow would we run our tests without getting screwed by whatever\nnon-standard values system-wide configuration may have?\nCurrently we disable tester's ~/.gitconfig by exporting HOME\nfrom t/test-lib.sh, but that will not work for this.\n\nI think we need to have a way to disable this setting, perhaps\nvia an environment variable.\n\nI do not think we need to support 'git config --system --set foo.bar baz'\nbut some people might have twisted minds ;-).\n"},{"id":"34618","messageId":"Pine.LNX.4.63.0702142049430.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6813","inReplyTo":"7vfy98o78i.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-14T19:54:41Z","receivedAt":"2007-02-14T19:54:41Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Feb 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> >> Stupid probably is too strong a word, but I think I'd agree we\n> >> should default it to $(prefix)/etc and have distros override it\n> >> in the Makefile.\n> >\n> > Fair enough. And my patch was not really complete. Please amend to spare \n> > me eternal shame:\n> > --\n> > [BROWN PAPERBAG PATCH ON TOP OF OTHER PATCH] \n> >\n> > It is $prefix/etc/gitconfig now, and works also if you do not\n> > `git config -l`. D'oh.\n> \n> How would we run our tests without getting screwed by whatever\n> non-standard values system-wide configuration may have?\n> Currently we disable tester's ~/.gitconfig by exporting HOME\n> from t/test-lib.sh, but that will not work for this.\n> \n> I think we need to have a way to disable this setting, perhaps\n> via an environment variable.\n\nYes. Just set GIT_CONFIG=/what/ever, and it no longer reads from \n~/.gitconfig or $prefix/etc/gitconfig.\n\nBut this possibly breaks down when creating a repository in a subdirectory \nof trash. Hmm.\n\n> I do not think we need to support 'git config --system --set foo.bar \n> baz' but some people might have twisted minds ;-).\n\n;-) Yes, I'd rather not have an administrator run git directly. But it \n_would_ be easy enough:\n\ndiff --git a/builtin-config.c b/builtin-config.c\nindex 0f9051d..a42d251 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -147,6 +152,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t\t} else {\n \t\t\t\tdie(\"$HOME not set\");\n \t\t\t}\n+\t\telse if (!strcmp(argv[1], \"--system-wide\")) {\n+\t\t\tsetenv(\"GIT_CONFIG\", ETC_GITCONFIG, 1);\n \t\t} else if (!strcmp(argv[1], \"--rename-section\")) {\n \t\t\tint ret;\n \t\t\tif (argc != 4)\n"},{"id":"34649","messageId":"Pine.LNX.4.63.0702142338450.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6813","inReplyTo":"Pine.LNX.4.63.0702142049430.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-14T22:39:20Z","receivedAt":"2007-02-14T22:39:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Feb 2007, Johannes Schindelin wrote:\n\n> diff --git a/builtin-config.c b/builtin-config.c\n> index 0f9051d..a42d251 100644\n> --- a/builtin-config.c\n> +++ b/builtin-config.c\n> @@ -147,6 +152,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n>  \t\t\t} else {\n>  \t\t\t\tdie(\"$HOME not set\");\n>  \t\t\t}\n> +\t\telse if (!strcmp(argv[1], \"--system-wide\")) {\n\nOoops. There is a \"}\" missing before \"else\".\n\nSorry,\nDscho\n"},{"id":"34677","messageId":"7v1wkshtxg.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"Pine.LNX.4.63.0702142049430.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-15T05:27:23Z","receivedAt":"2007-02-15T05:27:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> I think we need to have a way to disable this setting, perhaps\n>> via an environment variable.\n>\n> Yes. Just set GIT_CONFIG=/what/ever, and it no longer reads from \n> ~/.gitconfig or $prefix/etc/gitconfig.\n\nI think GIT_CONFIG and GIT_LOCAL_CONFIG environment variables\nare seriously misdesigned.  At least, I do not think of a sane\nway to make use of them.  For one thing, when they are set,\ntruly per-repository variables such as repositoryformatversion,\nlegacyheaders and sharedrepository are all ignored.\n\nWhat I would think is sensible would be simply to:\n\n - $GIT_CONFIG_SYSTEM environment, if set, names a file to be\n   read first.  It defaults to /etc/gitconfig.  You can set it\n   to /dev/null to avoid using /etc/gitconfig if you have\n   specific need.\n\n - Then $HOME/.gitconfig is read.\n\n - Then $GIT_DIR/config is read.\n\nInformation read from later files overrides the earlier ones, as\nbefore.\n\nI am not quite sure how $GIT_CONFIG and $GIT_CONFIG_LOCAL were\nmeant to be used.  Are there any *real* users?  With lack of\ninformation on the intended uses of these two environment\nvariables, I hacked up the following tweaks on top of the above\ndefined semantics, to imitate what I _think_ was the original\nintention.  The hacked one goes like this:\n\n - $GIT_CONFIG environment, if set, names a file to be read\n   first.  We read it first.\n\n - If $GIT_CONFIG is unset, then $GIT_CONFIG_SYSTEM (or\n   /etc/gitconfig) and $HOME/.gitconfig are read, as above.\n\n - Next file to be read is $GIT_CONFIG_LOCAL (if set) or\n   $GIT_DIR/config.  When reading this file, if we read from\n   $GIT_CONFIG earlier, we read only \"core.*\" section from it.\n\nThe difference from the original, aside from the additional\nbusiness with /etc/gitconfig, is that this updated one does read\nfrom $GIT_DIR/config (or $GIT_CONFIG_LOCAL) to avoid missing\nmore important per-repo variables.  Since I did not understand\nwhy $GIT_CONFIG makes the remaining configuration files to be\ntotally skipped in the original, I added hacks to make the last\nstep to read only minimally.\n\nI'd rather not to have the hacks to deal with GIT_CONFIG and\nGIT_CONFIG_LOCAL I did in this patch, but I do not know enough\nto tell if they are meaningless hacks to imitate ill-defined\noriginal semantics, or if they still cover useful use cases\nthese two environment variables were originally invented to\nsatisfy.\n\n---\n\n Makefile |   10 +++++--\n cache.h  |    4 +++\n config.c |   84 +++++++++++++++++++++++++++++++++++++++----------------------\n 3 files changed, 65 insertions(+), 33 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex ebecbbd..4232465 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -122,6 +122,7 @@ STRIP ?= strip\n \n prefix = $(HOME)\n bindir = $(prefix)/bin\n+etcdir = $(prefix)/etc\n gitexecdir = $(bindir)\n template_dir = $(prefix)/share/git-core/templates/\n # DESTDIR=\n@@ -142,7 +143,7 @@ GITWEB_FAVICON = git-favicon.png\n GITWEB_SITE_HEADER =\n GITWEB_SITE_FOOTER =\n \n-export prefix bindir gitexecdir template_dir\n+export prefix bindir etcdir gitexecdir template_dir\n \n CC = gcc\n AR = ar\n@@ -587,6 +588,7 @@ SHA1_HEADER_SQ = $(subst ','\\'',$(SHA1_HEADER))\n \n DESTDIR_SQ = $(subst ','\\'',$(DESTDIR))\n bindir_SQ = $(subst ','\\'',$(bindir))\n+etcdir_SQ = $(subst ','\\'',$(etcdir))\n gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n template_dir_SQ = $(subst ','\\'',$(template_dir))\n prefix_SQ = $(subst ','\\'',$(prefix))\n@@ -596,7 +598,9 @@ PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n \n LIBS = $(GITLIBS) $(EXTLIBS)\n \n-BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)\n+BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)'\n+BASIC_CFLAGS += -DGIT_CONFIG_SYSTEM='\"$(etcdir_SQ)/gitconfig\"'\n+BASIC_CFLAGS += $(COMPAT_CFLAGS)\n LIB_OBJS += $(COMPAT_OBJS)\n \n ALL_CFLAGS += $(BASIC_CFLAGS)\ndiff --git a/cache.h b/cache.h\nindex c62b0b0..2b4e26d 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -125,6 +125,10 @@ extern int cache_errno;\n #define TEMPLATE_DIR_ENVIRONMENT \"GIT_TEMPLATE_DIR\"\n #define CONFIG_ENVIRONMENT \"GIT_CONFIG\"\n #define CONFIG_LOCAL_ENVIRONMENT \"GIT_CONFIG_LOCAL\"\n+#define CONFIG_SYSTEM_ENVIRONMENT \"GIT_CONFIG_SYSTEM\"\n+#ifndef GIT_CONFIG_SYSTEM\n+#define GIT_CONFIG_SYSTEM \"/etc/gitconfig\"\n+#endif\n #define EXEC_PATH_ENVIRONMENT \"GIT_EXEC_PATH\"\n \n extern int is_bare_repository_cfg;\ndiff --git a/config.c b/config.c\nindex c938aa0..7ec0d9a 100644\n--- a/config.c\n+++ b/config.c\n@@ -107,7 +107,7 @@ static inline int iskeychar(int c)\n \treturn isalnum(c) || c == '-';\n }\n \n-static int get_value(config_fn_t fn, char *name, unsigned int len)\n+static int get_value(config_fn_t fn, char *name, unsigned int len, int core_only)\n {\n \tint c;\n \tchar *value;\n@@ -135,6 +135,8 @@ static int get_value(config_fn_t fn, char *name, unsigned int len)\n \t\tif (!value)\n \t\t\treturn -1;\n \t}\n+\tif (core_only && strncmp(name, \"core.\", 5))\n+\t\treturn 0;\n \treturn fn(name, value);\n }\n \n@@ -193,7 +195,7 @@ static int get_base_var(char *name)\n \t}\n }\n \n-static int git_parse_file(config_fn_t fn)\n+static int git_parse_file(config_fn_t fn, int core_only)\n {\n \tint comment = 0;\n \tint baselen = 0;\n@@ -225,7 +227,8 @@ static int git_parse_file(config_fn_t fn)\n \t\tif (!isalpha(c))\n \t\t\tbreak;\n \t\tvar[baselen] = tolower(c);\n-\t\tif (get_value(fn, var, baselen+1) < 0)\n+\n+\t\tif (get_value(fn, var, baselen+1, core_only) < 0)\n \t\t\tbreak;\n \t}\n \tdie(\"bad config file line %d in %s\", config_linenr, config_file_name);\n@@ -356,50 +359,71 @@ int git_default_config(const char *var, const char *value)\n \treturn 0;\n }\n \n-int git_config_from_file(config_fn_t fn, const char *filename)\n+static int git_config_from_file_1(config_fn_t fn, const char *filename, int core_only, int missing_ok)\n {\n \tint ret;\n \tFILE *f = fopen(filename, \"r\");\n \n-\tret = -1;\n+\tret = missing_ok ? 0 : -1;\n \tif (f) {\n \t\tconfig_file = f;\n \t\tconfig_file_name = filename;\n \t\tconfig_linenr = 1;\n-\t\tret = git_parse_file(fn);\n+\t\tret = git_parse_file(fn, core_only);\n \t\tfclose(f);\n \t\tconfig_file_name = NULL;\n \t}\n \treturn ret;\n }\n \n+int git_config_from_file(config_fn_t fn, const char *filename)\n+{\n+\treturn git_config_from_file_1(fn, filename, 0, 0);\n+}\n+\n int git_config(config_fn_t fn)\n {\n+\t/*\n+\t * If GIT_CONFIG environment is set, then it is read first.\n+\t * If GIT_CONFIG environment is not set,\n+\t *    GIT_CONFIG_SYSTEM (default /etc/gitconfig) is read next.\n+\t *    Then $HOME/.gitconfig is read.\n+\t *\n+\t * Then, if GIT_CONFIG_LOCAL is set, it is read.\n+\t * Otherwise \"$GIT_DIR/config\" is read.\n+\t * \n+\t * However, if we read from GIT_CONFIG environment earlier, we\n+\t * only read \"core.*\" section in the last step.\n+\t */\n \tint ret = 0;\n-\tchar *repo_config = NULL;\n-\tconst char *home = NULL, *filename;\n-\n-\t/* $GIT_CONFIG makes git read _only_ the given config file,\n-\t * $GIT_CONFIG_LOCAL will make it process it in addition to the\n-\t * global config file, the same way it would the per-repository\n-\t * config file otherwise. */\n-\tfilename = getenv(CONFIG_ENVIRONMENT);\n-\tif (!filename) {\n-\t\thome = getenv(\"HOME\");\n-\t\tfilename = getenv(CONFIG_LOCAL_ENVIRONMENT);\n-\t\tif (!filename)\n-\t\t\tfilename = repo_config = xstrdup(git_path(\"config\"));\n-\t}\n-\n-\tif (home) {\n-\t\tchar *user_config = xstrdup(mkpath(\"%s/.gitconfig\", home));\n-\t\tif (!access(user_config, R_OK))\n-\t\t\tret = git_config_from_file(fn, user_config);\n-\t\tfree(user_config);\n-\t}\n-\n-\tret += git_config_from_file(fn, filename);\n-\tfree(repo_config);\n+\tint core_only;\n+\tchar *cfg;\n+\tchar path[PATH_MAX];\n+\n+\tcfg = getenv(CONFIG_ENVIRONMENT);\n+\tif (cfg) {\n+\t\tret += git_config_from_file_1(fn, cfg, 0, 1);\n+\t\tcore_only = 1;\n+\t}\n+\telse {\n+\t\tcore_only = 0;\n+\t\tcfg = getenv(CONFIG_SYSTEM_ENVIRONMENT);\n+\t\tif (!cfg)\n+\t\t\tcfg = GIT_CONFIG_SYSTEM;\n+\t\tret += git_config_from_file_1(fn, cfg, 0, 1);\n+\n+\t\tcfg = getenv(\"HOME\");\n+\t\tif (cfg) {\n+\t\t\tsnprintf(path, sizeof(path), \"%s/.gitconfig\", cfg);\n+\t\t\tret += git_config_from_file_1(fn, path, 0, 1);\n+\t\t}\n+\t}\n+\tcfg = getenv(CONFIG_LOCAL_ENVIRONMENT);\n+\tif (!cfg) {\n+\t\tstrcpy(path, git_path(\"config\"));\n+\t\tcfg = path;\n+\t}\n+\tret += git_config_from_file_1(fn, cfg, core_only, 1);\n \treturn ret;\n }\n \n"},{"id":"34682","messageId":"7v4ppnhkps.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"7v1wkshtxg.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-15T08:46:23Z","receivedAt":"2007-02-15T08:46:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> I am not quite sure how $GIT_CONFIG and $GIT_CONFIG_LOCAL were\n> meant to be used.  Are there any *real* users?  With lack of\n> information on the intended uses of these two environment\n> variables, I hacked up the following tweaks on top of the above\n> defined semantics, to imitate what I _think_ was the original\n> intention.  The hacked one goes like this:\n>\n>  - $GIT_CONFIG environment, if set, names a file to be read\n>    first.  We read it first.\n>\n>  - If $GIT_CONFIG is unset, then $GIT_CONFIG_SYSTEM (or\n>    /etc/gitconfig) and $HOME/.gitconfig are read, as above.\n>\n>  - Next file to be read is $GIT_CONFIG_LOCAL (if set) or\n>    $GIT_DIR/config.  When reading this file, if we read from\n>    $GIT_CONFIG earlier, we read only \"core.*\" section from it.\n> ...\n\nAddendum.\n\nJudging from the way builtin-config.c::get_value() uses it, I\nthink whoever invented $GIT_CONFIG_LOCAL as a parallel to\n$GIT_INDEX_FILE and $GIT_OBJECT_DIRECTORY, in other words, what\nusually appear under $GIT_DIR can be placed somewhere completely\ndifferent.  So I think the above \"hack\" I described still honors\nits intended use.\n\nI am still not sure what good GIT_CONFIG would be to completely\noverride everything else, though.\n"},{"id":"34686","messageId":"20070215095903.GA6292@localdomain","threadId":"6813","inReplyTo":"7v4ppnhkps.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-02-15T09:59:03Z","receivedAt":"2007-02-15T09:59:03Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Junio C Hamano <junkio@cox.net> writes:\n> \n> > I am not quite sure how $GIT_CONFIG and $GIT_CONFIG_LOCAL were\n> > meant to be used.  Are there any *real* users?  With lack of\n> \n> Addendum.\n> \n> Judging from the way builtin-config.c::get_value() uses it, I\n> think whoever invented $GIT_CONFIG_LOCAL as a parallel to\n> $GIT_INDEX_FILE and $GIT_OBJECT_DIRECTORY, in other words, what\n> usually appear under $GIT_DIR can be placed somewhere completely\n> different.  So I think the above \"hack\" I described still honors\n> its intended use.\n> \n> I am still not sure what good GIT_CONFIG would be to completely\n> override everything else, though.\n\nI just started using GIT_CONFIG in the experimental version of\ngit-svn[1] which allows me to use .git/svn/config for tracking some\nmetadata bits.\n\nI didn't want to pollute the users' .git/config with automatically read\nand state data in .git/config; so I started using .git/svn/config to\navoid littering .git/svn/ with any tiny pieces of data I might need.\n\n-- \nEric Wong\n[1] - git://bogomips.org/git-svn\n"},{"id":"34687","messageId":"20070215100340.GA30015@localdomain","threadId":"6813","inReplyTo":"20070215095903.GA6292@localdomain","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-02-15T10:03:40Z","receivedAt":"2007-02-15T10:03:40Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Eric Wong <normalperson@yhbt.net> wrote:\n> Junio C Hamano <junkio@cox.net> wrote:\n> > Junio C Hamano <junkio@cox.net> writes:\n> > different.  So I think the above \"hack\" I described still honors\n> > its intended use.\n\nGIT_CONFIG continues to work here with the latest git-svn + your hack\n\n-- \nEric Wong\n"},{"id":"34689","messageId":"200702151019.25409.andyparkins@gmail.com","threadId":"6813","inReplyTo":"7vfy98snus.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-02-15T10:19:24Z","receivedAt":"2007-02-15T10:19:24Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Wednesday 2007 February 14 16:30, Junio C Hamano wrote:\n\n> Site-wide configuration for options that are potentially\n> compatibility-breaking is a bad idea on a multi-user machines,\n> and it was certainly the case back when our machines hosted many\n> diverse set of people.\n\nIsn't it more likely that on a multi-user machine all users are sharing one \ninstall of git - in which case you do want the upgrade of facilities to be \nsystem-wide.  Otherwise you have to tell every user to edit their .gitconfig \nto enable the new facilities - users shouldn't have to care about that sort \nof thing, that's what admins are for.\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIEE\nandyparkins@gmail.com\n"},{"id":"34692","messageId":"7vodnvemi7.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"20070215095903.GA6292@localdomain","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-15T10:36:00Z","receivedAt":"2007-02-15T10:36:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> Junio C Hamano <junkio@cox.net> wrote:\n> ...\n>> I am still not sure what good GIT_CONFIG would be to completely\n>> override everything else, though.\n>\n> I just started using GIT_CONFIG in the experimental version of\n> git-svn[1] which allows me to use .git/svn/config for tracking some\n> metadata bits.\n>\n> I didn't want to pollute the users' .git/config with automatically read\n> and state data in .git/config; so I started using .git/svn/config to\n> avoid littering .git/svn/ with any tiny pieces of data I might need.\n\nAh, so the intended usage is to use git-config to store in and\nretrieve from a file that does not have anything to do with the\ncore git data, and the using script would say:\n\n\tvalue=$(GIT_CONFIG=$that_extra_file git-config --get some.variable)\n        ... do whatever with $value which does not have\n        ... anything to do with git core itself\n        gitvalue=$(git-config --get some.git.variable)\n\t... use gitvalue which has some relevance to git core\n\tGIT_CONFIG=$that_extra_file git-config some.variable $newvalue\n\nI was more worried about the fact that the current GIT_CONFIG\ntotally *ignores* the variables in .git/config.  With a\nnarrower-than-usual umask, not reading core.sharedrepository\nwould result in quite an undesired result.  But as long as the\nintended usage follows the patter like above, in other words,\nthe user (a script) will never export GIT_CONFIG when using core\ngit plumbing or porcelain, I think it is Ok.\n"},{"id":"34693","messageId":"Pine.LNX.4.63.0702151126300.448@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6813","inReplyTo":"7v1wkshtxg.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-15T10:43:56Z","receivedAt":"2007-02-15T10:43:56Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Feb 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> >> I think we need to have a way to disable this setting, perhaps\n> >> via an environment variable.\n> >\n> > Yes. Just set GIT_CONFIG=/what/ever, and it no longer reads from \n> > ~/.gitconfig or $prefix/etc/gitconfig.\n> \n> I think GIT_CONFIG and GIT_LOCAL_CONFIG environment variables are \n> seriously misdesigned.\n\nOkay for GIT_LOCAL_CONFIG. I do not remember off-hand who wanted it \n(Jakub? Pasky?), but it was in the context of gitweb.\n\nHowever, GIT_CONFIG is meant to parse arbitrary config files. You can \nliterally say\n\n\tGIT_CONFIG=/windows/C/WINNT/system.ini git config drivers.wave\n\nand get the value for \"wave\" in system.ini, section [drivers].\n\nBTW I find the HOME mangling in test-lib.sh insane. Here's a replacement:\n\n-- snip --\n[PATCH] Make tests independent of global config files\n\nThis was done by setting $HOME to somewhere bogus. A better method is\nto reuse $GIT_CONFIG, which was invented for ignoring the global\nconfig file explicitely.\n\nTechnically, setting GIT_CONFIG=.git/config could be wrong, but it\npasses all the tests, and we can keep the tests that way.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n t/test-lib.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 37822fc..a403fe0 100755\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -255,8 +255,8 @@ test_done () {\n PATH=$(pwd)/..:$PATH\n GIT_EXEC_PATH=$(pwd)/..\n GIT_TEMPLATE_DIR=$(pwd)/../templates/blt\n-HOME=$(pwd)/trash\n-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR HOME\n+GIT_CONFIG=.git/config\n+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG\n \n GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git\n export GITPERLLIB\n-- snap --\n\n>  - $GIT_CONFIG_SYSTEM environment, if set, names a file to be\n>    read first.  It defaults to /etc/gitconfig.  You can set it\n>    to /dev/null to avoid using /etc/gitconfig if you have\n>    specific need.\n> \n>  - Then $HOME/.gitconfig is read.\n> \n>  - Then $GIT_DIR/config is read.\n\nYes, you can. But I'd rather not. The contents of /etc/gitconfig should be \nchanged with care, and _if_ they are changed, you should be forced to \noverride the settings explicitely in $HOME/.gitconfig.\n\nOf course, this assumes a sensible administrator.\n\n> I am not quite sure how $GIT_CONFIG and $GIT_CONFIG_LOCAL were meant to \n> be used.\n\nAs I said, I _think_ it was the gitweb people, who wanted to have this to \npoint at some gitweb specific, global (i.e. repo-independent) config.\n\n>  - $GIT_CONFIG environment, if set, names a file to be read\n>    first.  We read it first.\n> \n>  - If $GIT_CONFIG is unset, then $GIT_CONFIG_SYSTEM (or\n>    /etc/gitconfig) and $HOME/.gitconfig are read, as above.\n> \n>  - Next file to be read is $GIT_CONFIG_LOCAL (if set) or\n>    $GIT_DIR/config.  When reading this file, if we read from\n>    $GIT_CONFIG earlier, we read only \"core.*\" section from it.\n\nI am all for removing support for $GIT_CONFIG_LOCAL. IMHO it really does \nnot make sense, for the reasons you told in your email: important per-repo \ninformation would be ignored, but not global or system-wide settings.\n\nGIT_CONFIG should be used when reading a config which is totally unrelated \nto a repository. (Or for testing.)\n\nBut this \"core.*\" stuff is insane. Please no.\n\nBTW just to clarify a subtlety in the code (which looks ugly at first, but \nnothing else makes sense):\n\nWhen using --get-all, (with the patch I sent out earlier) git-config reads \n/etc/gitconfig first, then ~/.gitconfig, and then .git/config.\n\nWhen not using --get-all, it reads .git/config first, and if nothing was \nfound yet, reads ~/.gitconfig, and if still nothing was found, \n/etc/gitconfig.\n\nIt seems convoluted at first, but is the only way we can check for unique \nsettings. For example, if the system-wide default for \"color.diff\" is \n\"false\", but in your repo it is \"auto\", it should _not_ warn of ambiguous \nsettings, while it should warn if you have both settings in .git/config.\n\nOutside of git-config, such unique variables are always handled in a \nlast-wins manner, so we are safe.\n\nI would feel much better, though, if supporters of /etc/gitconfig spoke a \nlittle bit louder, before actually doing something about it.\n\nCiao,\nDscho\n"},{"id":"34699","messageId":"7vvei3d5n5.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"Pine.LNX.4.63.0702151126300.448@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-15T11:25:34Z","receivedAt":"2007-02-15T11:25:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Okay for GIT_LOCAL_CONFIG. I do not remember off-hand who wanted it \n> (Jakub? Pasky?), but it was in the context of gitweb.\n>\n> However, GIT_CONFIG is meant to parse arbitrary config files.\n> ...\n> But this \"core.*\" stuff is insane. Please no.\n\nOk, Eric's example and yours made it clear that GIT_CONFIG is an\ninterface meant to reuse (or abuse) git-config to read some file\nthat is not at all related to git, and should never be used by\nother plumbing.  As long as that is clear (could we have that in\nthe documentation, by the way, please?), I have no problem with\nthat.\n\nIn fact, I am very happy that we do not have to do that insane\n\"core.*\" stuff, which I thought was needed purely because\nsomebody was trying to use GIT_CONFIG to prevent plumbing and\nporcelain from reading core configuration variables that are per\nrepository in nature.\n\nAs I said in my other message, GIT_LOCAL_CONFIG is parallel to\nGIT_OBJECT_DIRECTORY and GIT_INDEX_FILE, and I am Ok with the\nway it is handled by the current code.\n\nI mildly disagree with you on having an ability to disable\n/etc/gitconfig.  This is necessary in the real world (in the\nsame sense as \"adduser\" can be told not to copy skeltons by\ncreating an empty home directory beforehand), even if we do not\nconsider the fact that it would help gaining repeatable results\nfrom our test scripts (remember, using GIT_CONFIG to make\nplumbing and porcelain read from there would set a bad example,\neven when it is pointing at .git/config).\n\nI've queued that insane \"core.*\" stuff in 'pu' and pushed out,\nbut I'll drop that topic altogether.  But before doing that,\nit's past my bedtime ;-).\n"},{"id":"34700","messageId":"7vr6srd5lf.fsf@assigned-by-dhcp.cox.net","threadId":"6813","inReplyTo":"200702151019.25409.andyparkins@gmail.com","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-15T11:26:36Z","receivedAt":"2007-02-15T11:26:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Parkins <andyparkins@gmail.com> writes:\n\n> On Wednesday 2007 February 14 16:30, Junio C Hamano wrote:\n>\n>> Site-wide configuration for options that are potentially\n>> compatibility-breaking is a bad idea on a multi-user machines,\n>> and it was certainly the case back when our machines hosted many\n>> diverse set of people.\n>\n> Isn't it more likely that on a multi-user machine all users are sharing one \n> install of git - in which case you do want the upgrade of facilities to be \n> system-wide.\n\nNot really.  Some repositories would need to be accessible by\npeople with older git coming over the network.  Some don't.\n"},{"id":"34705","messageId":"Pine.LNX.4.63.0702151302540.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"6813","inReplyTo":"7vvei3d5n5.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-02-15T12:05:13Z","receivedAt":"2007-02-15T12:05:13Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 15 Feb 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > Okay for GIT_LOCAL_CONFIG. I do not remember off-hand who wanted it \n> > (Jakub? Pasky?), but it was in the context of gitweb.\n> >\n> > However, GIT_CONFIG is meant to parse arbitrary config files.\n> > ...\n> > But this \"core.*\" stuff is insane. Please no.\n> \n> Ok, Eric's example and yours made it clear that GIT_CONFIG is an\n> interface meant to reuse (or abuse) git-config to read some file\n> that is not at all related to git, and should never be used by\n> other plumbing.  As long as that is clear (could we have that in\n> the documentation, by the way, please?), I have no problem with\n> that.\n\nI am no particularly good with documentation, but the good people who \nwanted this feature in the first place are.\n\n> I mildly disagree with you on having an ability to disable\n> /etc/gitconfig.\n\nI'm okay either way. But I thought /etc/gitconfig was not so much like \n/etc/skel/, but more like /etc/profile.\n\n> I've queued that insane \"core.*\" stuff in 'pu' and pushed out,\n> but I'll drop that topic altogether.  But before doing that,\n> it's past my bedtime ;-).\n\nHey, take it easy, now that Git \"snog\" is out!\n\nCiao,\nDscho\n"},{"id":"34797","messageId":"81b0412b0702160642h69b632f0w6c1decc4ec04c24a@mail.gmail.com","threadId":"6813","inReplyTo":"20070216143952.GA2478@steel.home","subject":"[PATCH] Allow config files to be included","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-02-16T14:42:30Z","receivedAt":"2007-02-16T14:42:30Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"The syntax is:\n\n    [include \"filename\"]\n\nwhich is somewhat branch/remote-alike. There are a few differences, though:\nfilenames happen to be long, so a backslash is supported to split the\nnames into multiple lines. No bare LF allowed, so this is illegal:\n    [include \"path/\n    name\"]\nOn the other hand, this is allowed:\n    [include \"path/\\\n    name\"]\n\nBackslash is just to quote characters (as in shell).\nOnly one quoted string allowed, so this is bad too:\n\n    [include \"path/\" \"name\"]\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\nThis is a resend, I have no idea what happened to original,\nbut it never appeared on vger. And this will probably horribly\ngarbled by gmail. Will see.\n\nAlex Riesen, Thu, Feb 15, 2007 12:35:57 +0100:\n> I suggest to ignore /etc/gitconfig completely if ~/.gitconfig exists,\n> but allow inclusion of /etc/gitconfig from ~/.gitconfig (there are\n> very singular and preciuos exceptions).\n\n config.c |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 100 insertions(+), 3 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex d821071..b42a7ea 100644\n--- a/config.c\n+++ b/config.c\n@@ -12,6 +12,57 @@\n static FILE *config_file;\n static const char *config_file_name;\n static int config_linenr;\n+\n+struct fileinfo\n+{\n+       char *name;\n+       int linenr;\n+       FILE *file;\n+       struct fileinfo *prev;\n+};\n+static struct fileinfo *config_stack = NULL;\n+\n+static void include_file(const char *filename)\n+{\n+       struct fileinfo *prev;\n+       FILE *file;\n+       file = fopen(filename, \"r\");\n+       if (!file) {\n+               error(\"ignored \\\"%s\\\": %s\", filename, strerror(errno));\n+               return;\n+       }\n+       prev = malloc(sizeof(*prev));\n+       prev->name = (char *)config_file_name;\n+       prev->linenr = config_linenr;\n+       prev->file = config_file;\n+       prev->prev = config_stack;\n+       config_stack = prev;\n+\n+       config_file = file;\n+       config_file_name = xstrdup(filename);\n+       config_linenr = 0;\n+}\n+\n+static FILE *pop_file(void)\n+{\n+       struct fileinfo *prev;\n+\n+       if (!config_stack)\n+               /* The last file on stack does not belong to us.\n+                * Free the names and close all included files. */\n+               return NULL;\n+\n+       free((void*)config_file_name);\n+       fclose(config_file);\n+       config_file = config_stack->file;\n+       config_file_name = config_stack->name;\n+       config_linenr = 0;\n+       prev = config_stack->prev;\n+       free(config_stack);\n+       config_stack = prev;\n+       return config_file;\n+}\n+\n static int get_next_char(void)\n {\n        int c;\n@@ -31,13 +82,51 @@ static int get_next_char(void)\n                if (c == '\\n')\n                        config_linenr++;\n                if (c == EOF) {\n-                       config_file = NULL;\n+                       config_file = pop_file();\n                        c = '\\n';\n                }\n        }\n        return c;\n }\n\n+static int parse_include(void)\n+{\n+       char name[PATH_MAX];\n+       int quote = 0, len = 0;\n+\n+       for (;;) {\n+               int c = get_next_char();\n+               if (len >= sizeof(name))\n+                       return -1;\n+               if (c == '\"') {\n+                       quote++;\n+                       continue;\n+               }\n+               if (c == '\\n')\n+                       /* do not allow bare \\n anywhere in path */\n+                       return -1;\n+               if (quote == 1) {\n+                       if (c == '\\\\') {\n+                               c = get_next_char();\n+                               if (c == '\\n')\n+                                       continue;\n+                       }\n+                       name[len++] = c;\n+               }\n+               if (quote == 2 && c == ']') {\n+                       do\n+                               c = get_next_char();\n+                       while (c != '\\n');\n+                       break;\n+               }\n+               if ((quote < 1 || quote >= 2) && !isspace(c) )\n+                       return -1;\n+       }\n+       name[len] = '\\0';\n+       include_file(name);\n+       return 0;\n+}\n+\n static char *parse_value(void)\n {\n        static char value[1024];\n@@ -181,8 +270,13 @@ static int get_base_var(char *name)\n                int c = get_next_char();\n                if (c == EOF)\n                        return -1;\n+               if (!isalpha(c) && !strncmp(name, \"include\", baselen) &&\n+                   config_file) {\n+                       ungetc(c, config_file);\n+                       return parse_include();\n+               }\n                if (c == ']')\n-                       return baselen;\n+                       return baselen ? baselen: -1;\n                if (isspace(c))\n                        return get_extended_base_var(name, baselen, c);\n                if (!iskeychar(c) && c != '.')\n@@ -216,8 +310,11 @@ static int git_parse_file(config_fn_t fn)\n                }\n                if (c == '[') {\n                        baselen = get_base_var(var);\n-                       if (baselen <= 0)\n+                       if (baselen < 0)\n                                break;\n+                       if (!baselen)\n+                               /* [include \"...\"]*/\n+                               continue;\n                        var[baselen++] = '.';\n                        var[baselen] = 0;\n                        continue;\n--\n1.5.0.138.g36f81\n"},{"id":"34798","messageId":"81b0412b0702160645t1212f70apc466b670066ef433@mail.gmail.com","threadId":"6813","inReplyTo":"81b0412b0702160642h69b632f0w6c1decc4ec04c24a@mail.gmail.com","subject":"Re: [PATCH] Allow config files to be included","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-02-16T14:45:40Z","receivedAt":"2007-02-16T14:45:40Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"The syntax is:\n\n    [include \"filename\"]\n\nwhich is somewhat branch/remote-alike. There are a few differences, though:\nfilenames happen to be long, so a backslash is supported to split the\nnames into multiple lines. No bare LF allowed, so this is illegal:\n    [include \"path/\n    name\"]\nOn the other hand, this is allowed:\n    [include \"path/\\\n    name\"]\n\nBackslash is just to quote characters (as in shell).\nOnly one quoted string allowed, so this is bad too:\n\n    [include \"path/\" \"name\"]\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n\n> This is a resend, I have no idea what happened to original,\n> but it never appeared on vger. And this will probably horribly\n> garbled by gmail. Will see.\n\nIt was horribly garbled by gmail. Resending as attachment.\n\n> Alex Riesen, Thu, Feb 15, 2007 12:35:57 +0100:\n> > I suggest to ignore /etc/gitconfig completely if ~/.gitconfig exists,\n> > but allow inclusion of /etc/gitconfig from ~/.gitconfig (there are\n> > very singular and preciuos exceptions).\n>\nconfig.c |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 100 insertions(+), 3 deletions(-)\n\n\nFrom 10c6dc89128fda0b4de89d69bd0ca2087f531a29 Mon Sep 17 00:00:00 2001\nFrom: Alex Riesen <raa@steel.home>\nDate: Thu, 15 Feb 2007 18:34:30 +0100\nSubject: [PATCH] Allow config files to be included\n\nThe syntax is:\n\n    [include \"filename\"]\n\nwhich is somewhat branch/remote-alike. There are a few differences, though:\nfilenames happen to be long, so a backslash is supported to split the\nnames into multiple lines. No bare LF allowed, so this is illegal:\n    [include \"path/\n    name\"]\nOn the other hand, this is allowed:\n    [include \"path/\\\n    name\"]\n\nBackslash is just to quote characters (as in shell).\nOnly one quoted string allowed, so this is bad too:\n\n    [include \"path/\" \"name\"]\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n config.c |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 100 insertions(+), 3 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex d821071..b42a7ea 100644\n--- a/config.c\n+++ b/config.c\n@@ -12,6 +12,57 @@\n static FILE *config_file;\n static const char *config_file_name;\n static int config_linenr;\n+\n+struct fileinfo\n+{\n+\tchar *name;\n+\tint linenr;\n+\tFILE *file;\n+\tstruct fileinfo *prev;\n+};\n+static struct fileinfo *config_stack = NULL;\n+\n+static void include_file(const char *filename)\n+{\n+\tstruct fileinfo *prev;\n+\tFILE *file;\n+\tfile = fopen(filename, \"r\");\n+\tif (!file) {\n+\t\terror(\"ignored \\\"%s\\\": %s\", filename, strerror(errno));\n+\t\treturn;\n+\t}\n+\tprev = malloc(sizeof(*prev));\n+\tprev->name = (char *)config_file_name;\n+\tprev->linenr = config_linenr;\n+\tprev->file = config_file;\n+\tprev->prev = config_stack;\n+\tconfig_stack = prev;\n+\n+\tconfig_file = file;\n+\tconfig_file_name = xstrdup(filename);\n+\tconfig_linenr = 0;\n+}\n+\n+static FILE *pop_file(void)\n+{\n+\tstruct fileinfo *prev;\n+\n+\tif (!config_stack)\n+\t\t/* The last file on stack does not belong to us.\n+\t\t * Free the names and close all included files. */\n+\t\treturn NULL;\n+\n+\tfree((void*)config_file_name);\n+\tfclose(config_file);\n+\tconfig_file = config_stack->file;\n+\tconfig_file_name = config_stack->name;\n+\tconfig_linenr = 0;\n+\tprev = config_stack->prev;\n+\tfree(config_stack);\n+\tconfig_stack = prev;\n+\treturn config_file;\n+}\n+\n static int get_next_char(void)\n {\n \tint c;\n@@ -31,13 +82,51 @@ static int get_next_char(void)\n \t\tif (c == '\\n')\n \t\t\tconfig_linenr++;\n \t\tif (c == EOF) {\n-\t\t\tconfig_file = NULL;\n+\t\t\tconfig_file = pop_file();\n \t\t\tc = '\\n';\n \t\t}\n \t}\n \treturn c;\n }\n \n+static int parse_include(void)\n+{\n+\tchar name[PATH_MAX];\n+\tint quote = 0, len = 0;\n+\n+\tfor (;;) {\n+\t\tint c = get_next_char();\n+\t\tif (len >= sizeof(name))\n+\t\t\treturn -1;\n+\t\tif (c == '\"') {\n+\t\t\tquote++;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (c == '\\n')\n+\t\t\t/* do not allow bare \\n anywhere in path */\n+\t\t\treturn -1;\n+\t\tif (quote == 1) {\n+\t\t\tif (c == '\\\\') {\n+\t\t\t\tc = get_next_char();\n+\t\t\t\tif (c == '\\n')\n+\t\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tname[len++] = c;\n+\t\t}\n+\t\tif (quote == 2 && c == ']') {\n+\t\t\tdo\n+\t\t\t\tc = get_next_char();\n+\t\t\twhile (c != '\\n');\n+\t\t\tbreak;\n+\t\t}\n+\t\tif ((quote < 1 || quote >= 2) && !isspace(c) )\n+\t\t\treturn -1;\n+\t}\n+\tname[len] = '\\0';\n+\tinclude_file(name);\n+\treturn 0;\n+}\n+\n static char *parse_value(void)\n {\n \tstatic char value[1024];\n@@ -181,8 +270,13 @@ static int get_base_var(char *name)\n \t\tint c = get_next_char();\n \t\tif (c == EOF)\n \t\t\treturn -1;\n+\t\tif (!isalpha(c) && !strncmp(name, \"include\", baselen) &&\n+\t\t    config_file) {\n+\t\t\tungetc(c, config_file);\n+\t\t\treturn parse_include();\n+\t\t}\n \t\tif (c == ']')\n-\t\t\treturn baselen;\n+\t\t\treturn baselen ? baselen: -1;\n \t\tif (isspace(c))\n \t\t\treturn get_extended_base_var(name, baselen, c);\n \t\tif (!iskeychar(c) && c != '.')\n@@ -216,8 +310,11 @@ static int git_parse_file(config_fn_t fn)\n \t\t}\n \t\tif (c == '[') {\n \t\t\tbaselen = get_base_var(var);\n-\t\t\tif (baselen <= 0)\n+\t\t\tif (baselen < 0)\n \t\t\t\tbreak;\n+\t\t\tif (!baselen)\n+\t\t\t\t/* [include \"...\"]*/\n+\t\t\t\tcontinue;\n \t\t\tvar[baselen++] = '.';\n \t\t\tvar[baselen] = 0;\n \t\t\tcontinue;\n-- \n1.5.0.138.g36f81\n\n"},{"id":"34969","messageId":"eravet$noq$1@sea.gmane.org","threadId":"6813","inReplyTo":"7vvei3d5n5.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] config: read system-wide defaults from /etc/gitconfig","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-02-19T01:47:00Z","receivedAt":"2007-02-19T01:47:00Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n>> Okay for GIT_LOCAL_CONFIG. I do not remember off-hand who wanted it \n>> (Jakub? Pasky?), but it was in the context of gitweb.\n>>\n>> However, GIT_CONFIG is meant to parse arbitrary config files.\n>> ...\n>> But this \"core.*\" stuff is insane. Please no.\n> \n> Ok, Eric's example and yours made it clear that GIT_CONFIG is an\n> interface meant to reuse (or abuse) git-config to read some file\n> that is not at all related to git, and should never be used by\n> other plumbing.  As long as that is clear (could we have that in\n> the documentation, by the way, please?), I have no problem with\n> that.\n> \n> In fact, I am very happy that we do not have to do that insane\n> \"core.*\" stuff, which I thought was needed purely because\n> somebody was trying to use GIT_CONFIG to prevent plumbing and\n> porcelain from reading core configuration variables that are per\n> repository in nature.\n> \n> As I said in my other message, GIT_LOCAL_CONFIG is parallel to\n> GIT_OBJECT_DIRECTORY and GIT_INDEX_FILE, and I am Ok with the\n> way it is handled by the current code.\n> \n> I mildly disagree with you on having an ability to disable\n> /etc/gitconfig.  This is necessary in the real world (in the\n> same sense as \"adduser\" can be told not to copy skeltons by\n> creating an empty home directory beforehand), even if we do not\n> consider the fact that it would help gaining repeatable results\n> from our test scripts (remember, using GIT_CONFIG to make\n> plumbing and porcelain read from there would set a bad example,\n> even when it is pointing at .git/config).\n\nHmmm... documentation of GIT_CONFIG and GIT_LOCAL_CONFIG is a bit\nbehind, I guess:\n\ngit-repo-config(1):\nENVIRONMENT\n       GIT_CONFIG\n              Take  the  configuration from the given file instead of .git/config.\n              Using the \"--global\" option forces this to ~/.gitconfig.\n\n       GIT_CONFIG_LOCAL\n              Currently the same as $GIT_CONFIG; when Git will support global con-\n              figuration  files, this will cause it to take the configuration from\n              the global configuration file in addition to the given file.\n\nIn my opionoin the logic should be: first read /etc/gitconfig, or\nGIT_SYSTEM_CONFIG, if it exists, then ~/.gitconfig, if it exists, then\n$GIT_DIR/config or GIT_LOCAL_CONFIG; if GIT_CONFIG is set, read only this.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}