* [PATCH 2/2] repo-config: learn the flag "--no-local"
@ 2006-06-08 11:31 Johannes Schindelin
2006-06-08 11:37 ` Lukas Sandström
2006-06-08 15:32 ` Aneesh Kumar K.V
0 siblings, 2 replies; 21+ messages in thread
From: Johannes Schindelin @ 2006-06-08 11:31 UTC (permalink / raw)
To: git; +Cc: junkio
Since there is a global config now, we need a way to access it
conveniently. Now you can say
git repo-config --no-local alias.l "log --stat -M ORIG_HEAD.."
to set the alias globally (it will be stored in ~/.gitconfig).
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
cache.h | 1 +
config.c | 23 ++++++++++++++++++-----
repo-config.c | 5 ++++-
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/cache.h b/cache.h
index d5d7fe4..14fe5c8 100644
--- a/cache.h
+++ b/cache.h
@@ -348,6 +348,7 @@ extern void packed_object_info_detail(st
/* Dumb servers support */
extern int update_server_info(int);
+extern int git_ignore_local_config;
typedef int (*config_fn_t)(const char *, const char *);
extern int git_default_config(const char *, const char *);
extern int git_config_from_file(config_fn_t fn, const char *);
diff --git a/config.c b/config.c
index 0987943..33f9109 100644
--- a/config.c
+++ b/config.c
@@ -10,6 +10,7 @@ #include <regex.h>
#define MAXNAME (256)
+int git_ignore_local_config = 0;
static FILE *config_file;
static const char *config_file_name;
static int config_linenr;
@@ -327,7 +328,8 @@ int git_config(config_fn_t fn)
ret = 0;
}
- ret += git_config_from_file(fn, git_path("config"));
+ if (!git_ignore_local_config)
+ ret += git_config_from_file(fn, git_path("config"));
return ret;
}
@@ -501,10 +503,20 @@ int git_config_set_multivar(const char*
int i, dot;
int fd = -1, in_fd;
int ret;
- char* config_filename = strdup(git_path("config"));
- char* lock_file = strdup(git_path("config.lock"));
+ char *config_filename, *lock_file;
const char* last_dot = strrchr(key, '.');
+ if (git_ignore_local_config) {
+ const char *home = getenv("HOME");
+ if (!home)
+ die("No home?");
+ config_filename = strdup(mkpath("%s/.gitconfig", home));
+ lock_file = strdup(mkpath("%s/.gitconfig.lock", home));
+ } else {
+ config_filename = strdup(git_path("config"));
+ lock_file = strdup(git_path("config.lock"));
+ }
+
/*
* Since "key" actually contains the section name and the real
* key name separated by a dot, we have to know where the dot is.
@@ -611,8 +623,9 @@ int git_config_set_multivar(const char*
* As a side effect, we make sure to transform only a valid
* existing config file.
*/
- if (git_config(store_aux)) {
- fprintf(stderr, "invalid config file\n");
+ if (git_config_from_file(store_aux, config_filename)) {
+ fprintf(stderr, "invalid config file: %s\n",
+ config_filename);
free(store.key);
if (store.value_regex != NULL) {
regfree(store.value_regex);
diff --git a/repo-config.c b/repo-config.c
index 59c2bfb..8c0bb20 100644
--- a/repo-config.c
+++ b/repo-config.c
@@ -97,7 +97,8 @@ static int get_value(const char* key_, c
if (do_all && global)
git_config_from_file(show_config, global);
- git_config_from_file(show_config, git_path("config"));
+ if (!git_ignore_local_config)
+ git_config_from_file(show_config, git_path("config"));
if (!do_all && !seen)
git_config_from_file(show_config, global);
@@ -125,6 +126,8 @@ int main(int argc, const char **argv)
type = T_BOOL;
else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l"))
return git_config(show_all_config);
+ else if (!strcmp(argv[1], "--no-local"))
+ git_ignore_local_config = 1;
else
break;
argc--;
--
1.4.0.rc1.g2f47-dirty
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 11:31 [PATCH 2/2] repo-config: learn the flag "--no-local" Johannes Schindelin
@ 2006-06-08 11:37 ` Lukas Sandström
2006-06-08 11:41 ` Johannes Schindelin
2006-06-08 15:32 ` Aneesh Kumar K.V
1 sibling, 1 reply; 21+ messages in thread
From: Lukas Sandström @ 2006-06-08 11:37 UTC (permalink / raw)
To: Git Mailing List; +Cc: Johannes Schindelin, junkio
Johannes Schindelin wrote:
> Since there is a global config now, we need a way to access it
> conveniently. Now you can say
>
> git repo-config --no-local alias.l "log --stat -M ORIG_HEAD.."
>
> to set the alias globally (it will be stored in ~/.gitconfig).
>
Wouldn't it make more sense to call the flag --global ?
/Lukas
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 11:37 ` Lukas Sandström
@ 2006-06-08 11:41 ` Johannes Schindelin
2006-06-08 13:37 ` Karl Hasselström
` (2 more replies)
0 siblings, 3 replies; 21+ messages in thread
From: Johannes Schindelin @ 2006-06-08 11:41 UTC (permalink / raw)
To: Lukas Sandström; +Cc: Git Mailing List, junkio
[-- Attachment #1: Type: TEXT/PLAIN, Size: 492 bytes --]
Hi,
On Thu, 8 Jun 2006, Lukas Sandström wrote:
> Johannes Schindelin wrote:
> > Since there is a global config now, we need a way to access it
> > conveniently. Now you can say
> >
> > git repo-config --no-local alias.l "log --stat -M ORIG_HEAD.."
> >
> > to set the alias globally (it will be stored in ~/.gitconfig).
> >
>
> Wouldn't it make more sense to call the flag --global ?
Sure, why not? Other opinions? (I will not add a test case until this is
resolved! ;-)
Ciao,
Dscho
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 11:41 ` Johannes Schindelin
@ 2006-06-08 13:37 ` Karl Hasselström
2006-06-08 15:35 ` Aneesh Kumar K.V
2006-06-08 14:06 ` Alex Riesen
2006-06-08 16:25 ` Junio C Hamano
2 siblings, 1 reply; 21+ messages in thread
From: Karl Hasselström @ 2006-06-08 13:37 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Lukas Sandström, Git Mailing List, junkio
On 2006-06-08 13:41:04 +0200, Johannes Schindelin wrote:
> On Thu, 8 Jun 2006, Lukas Sandström wrote:
>
> > Johannes Schindelin wrote:
> > > Since there is a global config now, we need a way to access it
> > > conveniently. Now you can say
> > >
> > > git repo-config --no-local alias.l "log --stat -M ORIG_HEAD.."
> > >
> > > to set the alias globally (it will be stored in ~/.gitconfig).
> > >
> >
> > Wouldn't it make more sense to call the flag --global ?
>
> Sure, why not? Other opinions? (I will not add a test case until
> this is resolved! ;-)
My vote goes to --no-local, but only if we also get a --no-no-local
flag with the opposite meaning. Otherwise, I'd prefer --global. :-)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 13:37 ` Karl Hasselström
@ 2006-06-08 15:35 ` Aneesh Kumar K.V
2006-06-08 18:36 ` Jakub Narebski
0 siblings, 1 reply; 21+ messages in thread
From: Aneesh Kumar K.V @ 2006-06-08 15:35 UTC (permalink / raw)
To: Karl Hasselstr?m; +Cc: Lukas Sandstr?m, Git Mailing List, junkio
On Thu, Jun 08, 2006 at 03:37:47PM +0200, Karl Hasselstr?m wrote:
> On 2006-06-08 13:41:04 +0200, Johannes Schindelin wrote:
>
> My vote goes to --no-local, but only if we also get a --no-no-local
> flag with the opposite meaning. Otherwise, I'd prefer --global. :-)
>
I guess it makes much sense to rename the command to git-config and say
git config alias.l -> for golbal config
git config --repo alias.l -> for repo specific config
-aneesh
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 15:35 ` Aneesh Kumar K.V
@ 2006-06-08 18:36 ` Jakub Narebski
2006-06-08 20:17 ` Johannes Schindelin
0 siblings, 1 reply; 21+ messages in thread
From: Jakub Narebski @ 2006-06-08 18:36 UTC (permalink / raw)
To: git
Aneesh Kumar K.V wrote:
> On Thu, Jun 08, 2006 at 03:37:47PM +0200, Karl Hasselstr?m wrote:
>> On 2006-06-08 13:41:04 +0200, Johannes Schindelin wrote:
>>
>> My vote goes to --no-local, but only if we also get a --no-no-local
>> flag with the opposite meaning. Otherwise, I'd prefer --global. :-)
>>
>
>
> I guess it makes much sense to rename the command to git-config and say
>
> git config alias.l -> for golbal config
> git config --repo alias.l -> for repo specific config
And legacy "git repo-config" as equivalent of "git config --repo", perhaps
implemented via alias mechanism (if there woul be system-wide coniguration
file, otherwise in skeleton/template).
--
Jakub Narebski
Warsaw, Poland
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 18:36 ` Jakub Narebski
@ 2006-06-08 20:17 ` Johannes Schindelin
0 siblings, 0 replies; 21+ messages in thread
From: Johannes Schindelin @ 2006-06-08 20:17 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
Hi,
On Thu, 8 Jun 2006, Jakub Narebski wrote:
> And legacy "git repo-config" as equivalent of "git config --repo", perhaps
> implemented via alias mechanism (if there woul be system-wide coniguration
> file, otherwise in skeleton/template).
Why use the alias mechanism? I, for one, never install git. So, this
solution is rather fragile. But there are better ways: the builtin
mechanism for one.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 11:41 ` Johannes Schindelin
2006-06-08 13:37 ` Karl Hasselström
@ 2006-06-08 14:06 ` Alex Riesen
2006-06-08 16:25 ` Junio C Hamano
2 siblings, 0 replies; 21+ messages in thread
From: Alex Riesen @ 2006-06-08 14:06 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Lukas Sandström, Git Mailing List, junkio
> >
> > Wouldn't it make more sense to call the flag --global ?
>
> Sure, why not? Other opinions? (I will not add a test case until this is
> resolved! ;-)
>
"--no-gitconfig" (as "--norc" in bash).
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 11:41 ` Johannes Schindelin
2006-06-08 13:37 ` Karl Hasselström
2006-06-08 14:06 ` Alex Riesen
@ 2006-06-08 16:25 ` Junio C Hamano
[not found] ` <20060608123652.6c3acf76.seanlkml@sympatico.ca>
2 siblings, 1 reply; 21+ messages in thread
From: Junio C Hamano @ 2006-06-08 16:25 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Lukas Sandström, Git Mailing List, junkio
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> Johannes Schindelin wrote:
> On Thu, 8 Jun 2006, Lukas Sandström wrote:
>> > Since there is a global config now, we need a way to access it
>> > conveniently. Now you can say
>> >
>> > git repo-config --no-local alias.l "log --stat -M ORIG_HEAD.."
>> >
>> > to set the alias globally (it will be stored in ~/.gitconfig).
>>
>> Wouldn't it make more sense to call the flag --global ?
>
> Sure, why not? Other opinions? (I will not add a test case until this is
> resolved! ;-)
The wording "--no-local" means you are looking at things
relative to a particular repository. I.e. some configuration
variables come from repository-local file, and others from
somewhere else. But I do not think that somewhere else is
"global". We are reading from $HOME, which is different
depending on who is interacting with that same repository. So I
would probably call the other one "--user" or something if I
were force to pick name.
But as you know, I am horrible at picking names, so please don't
stop this from coming up with a good name the list can agree
upon.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 11:31 [PATCH 2/2] repo-config: learn the flag "--no-local" Johannes Schindelin
2006-06-08 11:37 ` Lukas Sandström
@ 2006-06-08 15:32 ` Aneesh Kumar K.V
2006-06-08 20:18 ` Johannes Schindelin
1 sibling, 1 reply; 21+ messages in thread
From: Aneesh Kumar K.V @ 2006-06-08 15:32 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: junkio, git
On Thu, Jun 08, 2006 at 01:31:46PM +0200, Johannes Schindelin wrote:
>
> Since there is a global config now, we need a way to access it
> conveniently. Now you can say
>
> git repo-config --no-local alias.l "log --stat -M ORIG_HEAD.."
>
> to set the alias globally (it will be stored in ~/.gitconfig).
>
how about making the above
git config --repo alias.l "log --stat -M ORIG_HEAD.."
-aneesh
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 2/2] repo-config: learn the flag "--no-local"
2006-06-08 15:32 ` Aneesh Kumar K.V
@ 2006-06-08 20:18 ` Johannes Schindelin
0 siblings, 0 replies; 21+ messages in thread
From: Johannes Schindelin @ 2006-06-08 20:18 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: junkio, git
Hi,
On Thu, 8 Jun 2006, Aneesh Kumar K.V wrote:
> On Thu, Jun 08, 2006 at 01:31:46PM +0200, Johannes Schindelin wrote:
> >
> > Since there is a global config now, we need a way to access it
> > conveniently. Now you can say
> >
> > git repo-config --no-local alias.l "log --stat -M ORIG_HEAD.."
> >
> > to set the alias globally (it will be stored in ~/.gitconfig).
> >
>
> how about making the above
>
> git config --repo alias.l "log --stat -M ORIG_HEAD.."
IMHO it would be a sane thing to make this default. Most config variables
are repository dependent.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2006-06-08 21:24 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-08 11:31 [PATCH 2/2] repo-config: learn the flag "--no-local" Johannes Schindelin
2006-06-08 11:37 ` Lukas Sandström
2006-06-08 11:41 ` Johannes Schindelin
2006-06-08 13:37 ` Karl Hasselström
2006-06-08 15:35 ` Aneesh Kumar K.V
2006-06-08 18:36 ` Jakub Narebski
2006-06-08 20:17 ` Johannes Schindelin
2006-06-08 14:06 ` Alex Riesen
2006-06-08 16:25 ` Junio C Hamano
[not found] ` <20060608123652.6c3acf76.seanlkml@sympatico.ca>
2006-06-08 16:36 ` Sean
2006-06-08 20:24 ` Johannes Schindelin
[not found] ` <20060608163045.abd03553.seanlkml@sympatico.ca>
2006-06-08 20:30 ` Sean
2006-06-08 20:42 ` Johannes Schindelin
[not found] ` <20060608165525.e42917d2.seanlkml@sympatico.ca>
2006-06-08 20:55 ` Sean
2006-06-08 21:10 ` Johannes Schindelin
[not found] ` <20060608172315.15c2af3c.seanlkml@sympatico.ca>
2006-06-08 21:23 ` Sean
2006-06-08 20:55 ` Jakub Narebski
2006-06-08 21:03 ` Johannes Schindelin
2006-06-08 21:15 ` Jakub Narebski
2006-06-08 15:32 ` Aneesh Kumar K.V
2006-06-08 20:18 ` Johannes Schindelin
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).