* ~/.git/config ?
@ 2006-05-26 15:28 Anand Kumria
2006-05-26 16:33 ` Timo Hirvonen
` (2 more replies)
0 siblings, 3 replies; 25+ messages in thread
From: Anand Kumria @ 2006-05-26 15:28 UTC (permalink / raw)
To: git
Hi,
git is unable to construct a reasonable default email address in my
current environment. So, I use GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL
to override things.
This has worked well but, now, I need to vary the email address for some
repositories. Unfortunately the environment variables override
.git/config.
It would be good if things were like:
- try to construct one automagically
- use ~/.git/config (if available)
- use .git/config
- use environment variables
That way I could set my default email address in ~/.git/config and
override it as required for those repositories that need it.
Thanks,
Anand
--
`When any government, or any church for that matter, undertakes to say to
its subjects, "This you may not read, this you must not see, this you are
forbidden to know," the end result is tyranny and oppression no matter how
holy the motives' -- Robert A Heinlein, "If this goes on --"
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-26 15:28 ~/.git/config ? Anand Kumria
@ 2006-05-26 16:33 ` Timo Hirvonen
2006-05-26 16:37 ` Jakub Narebski
2006-05-26 16:38 ` Petr Baudis
2006-05-26 17:38 ` Junio C Hamano
2006-05-28 22:26 ` [PATCH] Read configuration also from ~/.gitrc Petr Baudis
2 siblings, 2 replies; 25+ messages in thread
From: Timo Hirvonen @ 2006-05-26 16:33 UTC (permalink / raw)
To: Anand Kumria; +Cc: git
Anand Kumria <wildfire@progsoc.uts.edu.au> wrote:
> Hi,
>
> git is unable to construct a reasonable default email address in my
> current environment. So, I use GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL
> to override things.
>
> This has worked well but, now, I need to vary the email address for some
> repositories. Unfortunately the environment variables override
> .git/config.
>
> It would be good if things were like:
> - try to construct one automagically
> - use ~/.git/config (if available)
> - use .git/config
> - use environment variables
>
> That way I could set my default email address in ~/.git/config and
> override it as required for those repositories that need it.
I backup my $HOME using git, so there's a .git directory in ~. I don't
think a global config file is really needed but it would be nice if
.git/config would override the environment variables, not the other way
around.
--
http://onion.dynserv.net/~timo/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-26 16:33 ` Timo Hirvonen
@ 2006-05-26 16:37 ` Jakub Narebski
2006-05-26 16:38 ` Petr Baudis
1 sibling, 0 replies; 25+ messages in thread
From: Jakub Narebski @ 2006-05-26 16:37 UTC (permalink / raw)
To: git
Timo Hirvonen wrote:
> Anand Kumria <wildfire@progsoc.uts.edu.au> wrote:
>
>> Hi,
>>
>> git is unable to construct a reasonable default email address in my
>> current environment. So, I use GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL
>> to override things.
>>
>> This has worked well but, now, I need to vary the email address for some
>> repositories. Unfortunately the environment variables override
>> .git/config.
>>
>> It would be good if things were like:
>> - try to construct one automagically
>> - use ~/.git/config (if available)
>> - use .git/config
>> - use environment variables
>>
>> That way I could set my default email address in ~/.git/config and
>> override it as required for those repositories that need it.
>
> I backup my $HOME using git, so there's a .git directory in ~. I don't
> think a global config file is really needed but it would be nice if
> .git/config would override the environment variables, not the other way
> around.
Well, I'm not sure if environmental variables overriding wouldn't make
invocations like 'GIT_DIR=something git command' possible.
There are templates, also for config. Currently git lacks user (not
repository) config file, e.g. ~/.gitconfig (common for all repositories).
--
Jakub Narebski
Warsaw, Poland
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-26 16:33 ` Timo Hirvonen
2006-05-26 16:37 ` Jakub Narebski
@ 2006-05-26 16:38 ` Petr Baudis
2006-05-26 17:05 ` Timo Hirvonen
2006-05-27 2:36 ` Pavel Roskin
1 sibling, 2 replies; 25+ messages in thread
From: Petr Baudis @ 2006-05-26 16:38 UTC (permalink / raw)
To: Timo Hirvonen; +Cc: Anand Kumria, git
Dear diary, on Fri, May 26, 2006 at 06:33:25PM CEST, I got a letter
where Timo Hirvonen <tihirvon@gmail.com> said that...
> I backup my $HOME using git, so there's a .git directory in ~.
Then it should be called ~/.gitconfig. :-)
> I don't think a global config file is really needed but it would be
> nice if .git/config would override the environment variables, not the
> other way around.
Then you have no other way to override .git/config e.g. when committing
patches submitted by other people.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-26 16:38 ` Petr Baudis
@ 2006-05-26 17:05 ` Timo Hirvonen
2006-05-26 17:11 ` Petr Baudis
2006-05-27 2:36 ` Pavel Roskin
1 sibling, 1 reply; 25+ messages in thread
From: Timo Hirvonen @ 2006-05-26 17:05 UTC (permalink / raw)
To: Petr Baudis; +Cc: wildfire, git
Petr Baudis <pasky@suse.cz> wrote:
> Dear diary, on Fri, May 26, 2006 at 06:33:25PM CEST, I got a letter
> where Timo Hirvonen <tihirvon@gmail.com> said that...
> > I backup my $HOME using git, so there's a .git directory in ~.
>
> Then it should be called ~/.gitconfig. :-)
I just wanted to point the fact that ~/.git/ could not be used :)
> > I don't think a global config file is really needed but it would be
> > nice if .git/config would override the environment variables, not the
> > other way around.
>
> Then you have no other way to override .git/config e.g. when committing
> patches submitted by other people.
git commit --author "name <email>"
--
http://onion.dynserv.net/~timo/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-26 17:05 ` Timo Hirvonen
@ 2006-05-26 17:11 ` Petr Baudis
0 siblings, 0 replies; 25+ messages in thread
From: Petr Baudis @ 2006-05-26 17:11 UTC (permalink / raw)
To: Timo Hirvonen; +Cc: wildfire, git
Dear diary, on Fri, May 26, 2006 at 07:05:26PM CEST, I got a letter
where Timo Hirvonen <tihirvon@gmail.com> said that...
> > > I don't think a global config file is really needed but it would be
> > > nice if .git/config would override the environment variables, not the
> > > other way around.
> >
> > Then you have no other way to override .git/config e.g. when committing
> > patches submitted by other people.
>
> git commit --author "name <email>"
Except that this just sets the environment variables for you. :-)
Now, you could do some really funny stuff with overriding the
environment variables at git commit's entry point with .git/config
stuff, then possibly setting them again in case --author was passed, but
I seriously think such a confusion is not worth it.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-26 15:28 ~/.git/config ? Anand Kumria
2006-05-26 16:33 ` Timo Hirvonen
@ 2006-05-26 17:38 ` Junio C Hamano
2006-05-28 22:26 ` [PATCH] Read configuration also from ~/.gitrc Petr Baudis
2 siblings, 0 replies; 25+ messages in thread
From: Junio C Hamano @ 2006-05-26 17:38 UTC (permalink / raw)
To: Anand Kumria; +Cc: git
Anand Kumria <wildfire@progsoc.uts.edu.au> writes:
> It would be good if things were like:
> - try to construct one automagically
> - use ~/.git/config (if available)
> - use .git/config
> - use environment variables
>
> That way I could set my default email address in ~/.git/config and
> override it as required for those repositories that need it.
If you mean by the above "do all of these and take the last
value that was available", that sounds sane. Except perhaps I
would suggest to use ~/.git-config instead. Some people seem to
want to track their home directory with git, and that way, your
personal fallback default file can be version controlled.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-26 16:38 ` Petr Baudis
2006-05-26 17:05 ` Timo Hirvonen
@ 2006-05-27 2:36 ` Pavel Roskin
2006-05-27 2:57 ` Petr Baudis
2006-05-27 8:50 ` ~/.git/config ? Nikolai Weibull
1 sibling, 2 replies; 25+ messages in thread
From: Pavel Roskin @ 2006-05-27 2:36 UTC (permalink / raw)
To: Petr Baudis; +Cc: Timo Hirvonen, Anand Kumria, git
On Fri, 2006-05-26 at 18:38 +0200, Petr Baudis wrote:
> Dear diary, on Fri, May 26, 2006 at 06:33:25PM CEST, I got a letter
> where Timo Hirvonen <tihirvon@gmail.com> said that...
> > I backup my $HOME using git, so there's a .git directory in ~.
>
> Then it should be called ~/.gitconfig. :-)
No, make it .gitrc for compatibility with .cvsrc, .lynxrc and others.
I know, it's becoming a bikeshed issue :-)
--
Regards,
Pavel Roskin
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-27 2:36 ` Pavel Roskin
@ 2006-05-27 2:57 ` Petr Baudis
2006-05-27 3:20 ` Linus Torvalds
2006-05-27 8:50 ` ~/.git/config ? Nikolai Weibull
1 sibling, 1 reply; 25+ messages in thread
From: Petr Baudis @ 2006-05-27 2:57 UTC (permalink / raw)
To: Pavel Roskin; +Cc: Timo Hirvonen, Anand Kumria, git
Dear diary, on Sat, May 27, 2006 at 04:36:22AM CEST, I got a letter
where Pavel Roskin <proski@gnu.org> said that...
> On Fri, 2006-05-26 at 18:38 +0200, Petr Baudis wrote:
> > Dear diary, on Fri, May 26, 2006 at 06:33:25PM CEST, I got a letter
> > where Timo Hirvonen <tihirvon@gmail.com> said that...
> > > I backup my $HOME using git, so there's a .git directory in ~.
> >
> > Then it should be called ~/.gitconfig. :-)
>
> No, make it .gitrc for compatibility with .cvsrc, .lynxrc and others.
~/.gitrc might get useful for actually doing what ~/.cvsrc or ~/.cgrc
does, that is providing default options for git commands. ~/.gitconfig
would just give you per-user defaults for the repository config file.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-27 2:57 ` Petr Baudis
@ 2006-05-27 3:20 ` Linus Torvalds
2006-05-27 3:36 ` Linus Torvalds
` (3 more replies)
0 siblings, 4 replies; 25+ messages in thread
From: Linus Torvalds @ 2006-05-27 3:20 UTC (permalink / raw)
To: Petr Baudis; +Cc: Pavel Roskin, Timo Hirvonen, Anand Kumria, git
On Sat, 27 May 2006, Petr Baudis wrote:
>
> ~/.gitrc might get useful for actually doing what ~/.cvsrc or ~/.cgrc
> does, that is providing default options for git commands. ~/.gitconfig
> would just give you per-user defaults for the repository config file.
I don't think the two are necessarily any different.
I do think that
(a) we might as well use the same syntax. There's no point in having
different syntax for the files, even if they end up having slightly
different usage.
(b) a "user-wide" config file would tend to have different things in it
than a per-repository one, but some of the things it would have in it
are the things that we currently put in the per-repository one.
Notably exactly the "user.name" and "user.email" values.
(c) having a user- (and perhaps a system-) wide config file would make
some things that we do not _yet_ support in the .git/config file
format more natural, but that doesn't necessarily mean that having
them on a per-repo basis would be wrong either.
As an example of (c), let's say that somebody wants to use the CVS aliases
with git. They've used cvs for years, and as a result their brain has
atrophied, and they have a really hard time teaching their fingers to
write "git commit" when they want to write "cvs ci".
So they would do "alias cvs git" in a desperate attempt to save themselves
from CVS, and then add
[alias "co"]
cmd = commit -a
to their .gitrc file. Now, the only thing we'd need to do is to teach
"git.c" to parse that simple "alias.$1.command" variable, and that really
sounds pretty damn easy, no?
And that really does make more sense in a user-wide ".gitrc" file. But at
the same time, there's really no reason to _disallow_ it from the
repo-private .git/config file either. For example, you could do
[alias "publish"]
cmd = push public.site.com:/pub/scm/my-public-repo
and that is somethign that actually makes sense as a per-repository
command alias, so that "git publish" does the right thing for just _that_
repository.
So I would argue that yes, ".gitrc" makes sense, and no, we shouldn't have
a separate ".gitrc" and ".gitconfig", because I think what we really would
want is a way to do default .git/config entries, and that it is _also_ a
very natural way to add some things that we don't do yet.
Linus
PS. I really like my [alias "cmd"] idea. _All_ my ideas are great, of
course, but this one seems even better than some others. No?
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-27 3:20 ` Linus Torvalds
@ 2006-05-27 3:36 ` Linus Torvalds
2006-05-27 4:43 ` Junio C Hamano
2006-05-27 3:40 ` Jakub Narebski
` (2 subsequent siblings)
3 siblings, 1 reply; 25+ messages in thread
From: Linus Torvalds @ 2006-05-27 3:36 UTC (permalink / raw)
To: Petr Baudis; +Cc: Pavel Roskin, Timo Hirvonen, Anand Kumria, git
On Fri, 26 May 2006, Linus Torvalds wrote:
>
> So they would do "alias cvs git" in a desperate attempt to save themselves
> from CVS, and then add
>
> [alias "co"]
> cmd = commit -a
That, of course, would be confusing.
It should be "ci" for commit, and "co" for "checkout".
Duh. Chalk it up to me not having used cvs in the last three or four years
or so (we used it at transmeta, although I can hope that they've since
seen the light ;).
Linus
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-27 3:20 ` Linus Torvalds
2006-05-27 3:36 ` Linus Torvalds
@ 2006-05-27 3:40 ` Jakub Narebski
2006-05-27 9:11 ` Junio C Hamano
2006-05-27 12:52 ` Horst von Brand
3 siblings, 0 replies; 25+ messages in thread
From: Jakub Narebski @ 2006-05-27 3:40 UTC (permalink / raw)
To: git
Linus Torvalds wrote:
> PS. I really like my [alias "cmd"] idea. _All_ my ideas are great, of
> course, but this one seems even better than some others. No?
So, would we use it also for default options of commands, like
[alias "log"]
cmd = log -p -M -C
(we could implement "git whatchanges" as an alias, keeping it's man page, or
sharing it with "git log").
--
Jakub Narebski
Warsaw, Poland
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-27 3:36 ` Linus Torvalds
@ 2006-05-27 4:43 ` Junio C Hamano
0 siblings, 0 replies; 25+ messages in thread
From: Junio C Hamano @ 2006-05-27 4:43 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
Linus Torvalds <torvalds@osdl.org> writes:
>> [alias "co"]
>> cmd = commit -a
>
> That, of course, would be confusing.
>
> It should be "ci" for commit, and "co" for "checkout".
>
> Duh. Chalk it up to me not having used cvs in the last three or four years
> or so (we used it at transmeta, although I can hope that they've since
> seen the light ;).
>
> Linus
You are lucky ;-).
The alias would be a nice addition -- I can get rid of the hack
I have for show-branch. We would need an argument splitter, but
that should be trivial.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-27 2:36 ` Pavel Roskin
2006-05-27 2:57 ` Petr Baudis
@ 2006-05-27 8:50 ` Nikolai Weibull
2006-05-27 9:09 ` Timo Hirvonen
1 sibling, 1 reply; 25+ messages in thread
From: Nikolai Weibull @ 2006-05-27 8:50 UTC (permalink / raw)
To: Pavel Roskin; +Cc: Petr Baudis, Timo Hirvonen, Anand Kumria, git
On 5/27/06, Pavel Roskin <proski@gnu.org> wrote:
> On Fri, 2006-05-26 at 18:38 +0200, Petr Baudis wrote:
> > Dear diary, on Fri, May 26, 2006 at 06:33:25PM CEST, I got a letter
> > where Timo Hirvonen <tihirvon@gmail.com> said that...
> > > I backup my $HOME using git, so there's a .git directory in ~.
> >
> > Then it should be called ~/.gitconfig. :-)
>
> No, make it .gitrc for compatibility with .cvsrc, .lynxrc and others.
>
> I know, it's becoming a bikeshed issue :-)
I want to paint part of it as well!
Wouldn't we be futureproofing ourselves by stuffing it in a
subdirectory instead? What if we want to add more files later?
Also, can we please make sure to make the location of the file (or
directory) configurable through an environment variable, e.g.,
GIT_CONFIG, GIT_USER_CONFIG, GIT_HOME, or GIT_USER_HOME?
Peace.
nikolai
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-27 8:50 ` ~/.git/config ? Nikolai Weibull
@ 2006-05-27 9:09 ` Timo Hirvonen
0 siblings, 0 replies; 25+ messages in thread
From: Timo Hirvonen @ 2006-05-27 9:09 UTC (permalink / raw)
To: Nikolai Weibull; +Cc: proski, pasky, wildfire, git
"Nikolai Weibull" <now@bitwi.se> wrote:
> On 5/27/06, Pavel Roskin <proski@gnu.org> wrote:
> > On Fri, 2006-05-26 at 18:38 +0200, Petr Baudis wrote:
> > >
> > > Then it should be called ~/.gitconfig. :-)
> >
> > No, make it .gitrc for compatibility with .cvsrc, .lynxrc and others.
> >
> > I know, it's becoming a bikeshed issue :-)
>
> I want to paint part of it as well!
>
> Wouldn't we be futureproofing ourselves by stuffing it in a
> subdirectory instead? What if we want to add more files later?
Makes sense, we may want to put templates to ~/.gitsomething/templates/.
--
http://onion.dynserv.net/~timo/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-27 3:20 ` Linus Torvalds
2006-05-27 3:36 ` Linus Torvalds
2006-05-27 3:40 ` Jakub Narebski
@ 2006-05-27 9:11 ` Junio C Hamano
2006-05-27 12:52 ` Horst von Brand
3 siblings, 0 replies; 25+ messages in thread
From: Junio C Hamano @ 2006-05-27 9:11 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
Linus Torvalds <torvalds@osdl.org> writes:
> On Sat, 27 May 2006, Petr Baudis wrote:
>>
>> ~/.gitrc might get useful for actually doing what ~/.cvsrc or ~/.cgrc
>> does, that is providing default options for git commands. ~/.gitconfig
>> would just give you per-user defaults for the repository config file.
>
> I don't think the two are necessarily any different.
Me neither. Default options to fall back on if repository
configuration does not specify them and when environments do not
override them -- that's exactly "per-user defaults", nothing else.
Earlier I suggested ~/.git-config, but anything other than
~/.git/config is OK. ~/.gitrc is fine. And the order suggested
by Anand sounded fine.
- use environment (if the value is obtained, stop here)
- use .git/config (if the value is obtained, stop here)
- use ~/.git-config (if the value is obtained, stop here)
- do whatever the program does by default.
> (a) we might as well use the same syntax. There's no point in having
> different syntax for the files, even if they end up having slightly
> different usage.
Absolutely.
> (b) a "user-wide" config file would tend to have different things in it
> than a per-repository one, but some of the things it would have in it
> are the things that we currently put in the per-repository one.
> Notably exactly the "user.name" and "user.email" values.
Yes. Also "preference" kind of things as opposed to "per
project policy" such as apply.whitespace.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: ~/.git/config ?
2006-05-27 3:20 ` Linus Torvalds
` (2 preceding siblings ...)
2006-05-27 9:11 ` Junio C Hamano
@ 2006-05-27 12:52 ` Horst von Brand
2006-05-28 21:59 ` [PATCH] Support for configurable git command aliases Petr Baudis
3 siblings, 1 reply; 25+ messages in thread
From: Horst von Brand @ 2006-05-27 12:52 UTC (permalink / raw)
To: Linus Torvalds
Cc: Petr Baudis, Pavel Roskin, Timo Hirvonen, Anand Kumria, git
Linus Torvalds <torvalds@osdl.org> wrote:
> On Sat, 27 May 2006, Petr Baudis wrote:
> >
> > ~/.gitrc might get useful for actually doing what ~/.cvsrc or ~/.cgrc
> > does, that is providing default options for git commands. ~/.gitconfig
> > would just give you per-user defaults for the repository config file.
Yep.
[...]
> So they would do "alias cvs git" in a desperate attempt to save themselves
> from CVS, and then add
>
> [alias "co"]
> cmd = commit -a
I don't like this syntax. What other stuff (beside "cmd") would be under
"[alias "co"]? Why not simply:
[alias]
co = commit -a
publish = push public.site.com:/pub/scm/my-public-repo
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH] Support for configurable git command aliases
2006-05-27 12:52 ` Horst von Brand
@ 2006-05-28 21:59 ` Petr Baudis
2006-05-28 22:57 ` Jakub Narebski
2006-05-29 2:01 ` Junio C Hamano
0 siblings, 2 replies; 25+ messages in thread
From: Petr Baudis @ 2006-05-28 21:59 UTC (permalink / raw)
To: Horst von Brand
Cc: Linus Torvalds, Pavel Roskin, Timo Hirvonen, Anand Kumria, git
Dear diary, on Sat, May 27, 2006 at 02:52:35PM CEST, I got a letter
where Horst von Brand <vonbrand@inf.utfsm.cl> said that...
> > So they would do "alias cvs git" in a desperate attempt to save themselves
> > from CVS, and then add
> >
> > [alias "co"]
> > cmd = commit -a
>
> I don't like this syntax. What other stuff (beside "cmd") would be under
> "[alias "co"]? Why not simply:
>
> [alias]
> co = commit -a
> publish = push public.site.com:/pub/scm/my-public-repo
Nice, I like this.
Well, the following isn't exactly the nicest code I have ever written...
But it seems to work. ;-)
---
This patch adds support for configurable aliases for git commands -
"alias.WHATEVER = which ever" will kick in when you do "git WHATEVER"
and substitute WHATEVER with "which ever" (splitted to arguments at
whitespaces).
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
Documentation/config.txt | 5 ++++
Documentation/git.txt | 3 +++
git.c | 52 ++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index d1a4bec..ce616e3 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -83,6 +83,11 @@ core.warnAmbiguousRefs::
If true, git will warn you if the ref name you passed it is ambiguous
and might match multiple refs in the .git/refs/ tree. True by default.
+alias.*::
+ Command aliases for the gitlink:git[1] command wrapper - e.g.
+ after defining "alias.last = cat-file commit HEAD", the invocation
+ "git last" is equivalent to "git cat-file commit HEAD".
+
apply.whitespace::
Tells `git-apply` how to handle whitespaces, in the same way
as the '--whitespace' option. See gitlink:git-apply[1].
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 24ca55d..e474bdf 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -21,6 +21,9 @@ link:everyday.html[Everyday Git] for a u
"man git-commandname" for documentation of each command. CVS users may
also want to read link:cvs-migration.html[CVS migration].
+The COMMAND is either a name of a Git command (see below) or an alias
+as defined in the configuration file (see gitlink:git-repo-config[1]).
+
OPTIONS
-------
--version::
diff --git a/git.c b/git.c
index 10ea934..0d9cd0e 100644
--- a/git.c
+++ b/git.c
@@ -10,6 +10,7 @@ #include <limits.h>
#include <stdarg.h>
#include "git-compat-util.h"
#include "exec_cmd.h"
+#include "cache.h" /* setup_git_directory_gently() */
#include "builtin.h"
@@ -87,13 +88,27 @@ static void handle_internal_command(int
}
}
+static const char *cmd;
+static char *cmdalias;
+
+int git_alias_config(const char *var, const char *value)
+{
+ if (strncmp(var, "alias.", 6))
+ return 0;
+ var += /* strlen("alias.") */ 6;
+ if (!strcmp(var, cmd))
+ cmdalias = strdup(value);
+ return 0;
+}
+
int main(int argc, const char **argv, char **envp)
{
- const char *cmd = argv[0];
- char *slash = strrchr(cmd, '/');
+ char *slash = strrchr(argv[0], '/');
char git_command[PATH_MAX + 1];
const char *exec_path = NULL;
+ cmd = argv[0];
+
/*
* Take the basename of argv[0] as the command
* name, and the dirname as the default exec_path
@@ -165,6 +180,39 @@ int main(int argc, const char **argv, ch
}
argv[0] = cmd;
+ /* Is this an alias? */
+ {
+ /* XXX: We do a redundant git directory detection. */
+ int nongit = 0;
+ const char *subdir = setup_git_directory_gently(&nongit);
+
+ if (!nongit) {
+ git_config(git_alias_config);
+ if (cmdalias) {
+ /* More than the worst case: */
+ const char **argv2 = malloc((strlen(cmdalias) + argc) * sizeof(char*));
+ int argc2 = 0, i = 1;
+
+ while (cmdalias && *cmdalias) {
+ argv2[argc2++] = strsep(&cmdalias, " \t");
+ if (cmdalias)
+ while (*cmdalias == ' ' || *cmdalias == '\t')
+ cmdalias++;
+ }
+ while (i < argc) {
+ argv2[argc2++] = argv[i++];
+ }
+ argv2[argc2] = NULL;
+ argv = argv2;
+ argc = argc2;
+ }
+ }
+
+ /* Go back so that the commands start with clean table */
+ if (subdir)
+ chdir(subdir);
+ }
+
/*
* We search for git commands in the following order:
* - git_exec_path()
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH] Read configuration also from ~/.gitrc
2006-05-26 15:28 ~/.git/config ? Anand Kumria
2006-05-26 16:33 ` Timo Hirvonen
2006-05-26 17:38 ` Junio C Hamano
@ 2006-05-28 22:26 ` Petr Baudis
2006-05-29 7:20 ` Johannes Schindelin
2 siblings, 1 reply; 25+ messages in thread
From: Petr Baudis @ 2006-05-28 22:26 UTC (permalink / raw)
To: Anand Kumria; +Cc: git
Hi,
Dear diary, on Fri, May 26, 2006 at 05:28:37PM CEST, I got a letter
where Anand Kumria <wildfire@progsoc.uts.edu.au> said that...
> git is unable to construct a reasonable default email address in my
> current environment. So, I use GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL
> to override things.
>
> This has worked well but, now, I need to vary the email address for some
> repositories. Unfortunately the environment variables override
> .git/config.
>
> It would be good if things were like:
> - try to construct one automagically
> - use ~/.git/config (if available)
> - use .git/config
> - use environment variables
>
> That way I could set my default email address in ~/.git/config and
> override it as required for those repositories that need it.
hmm, might it be as simple as this?
---
This command makes Git read configuration from ~/.gitrc in addition
to the per-repository .git/config configuration file, and updates
the documentation accordingly (and also expands it a little).
Idea by Anand Kumria.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
Documentation/git-commit-tree.txt | 9 +++++----
Documentation/git-repo-config.txt | 6 +++---
Documentation/git-var.txt | 5 +++--
Documentation/git.txt | 15 +++++++++++----
config.c | 6 +++++-
5 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt
index 41d1a1c..1b0d102 100644
--- a/Documentation/git-commit-tree.txt
+++ b/Documentation/git-commit-tree.txt
@@ -49,8 +49,9 @@ A commit encapsulates:
- committer name and email and the commit time.
If not provided, "git-commit-tree" uses your name, hostname and domain to
-provide author and committer info. This can be overridden by
-either `.git/config` file, or using the following environment variables.
+provide author and committer info. This can be overridden by either the
+`~/.gitrc` file, the `.git/config` file, or using the following
+environment variables.
GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL
@@ -60,8 +61,8 @@ either `.git/config` file, or using the
(nb "<", ">" and "\n"s are stripped)
-In `.git/config` file, the following items are used for GIT_AUTHOR_NAME and
-GIT_AUTHOR_EMAIL:
+In the configuration file, the following items are used for GIT_AUTHOR_NAME
+and GIT_AUTHOR_EMAIL:
[user]
name = "Your Name"
diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt
index 660c18f..bb7f81f 100644
--- a/Documentation/git-repo-config.txt
+++ b/Documentation/git-repo-config.txt
@@ -3,7 +3,7 @@ git-repo-config(1)
NAME
----
-git-repo-config - Get and set options in .git/config
+git-repo-config - Get and set git runtime configuration options
SYNOPSIS
@@ -37,7 +37,7 @@ no checks or transformations are perform
This command will fail if:
-. The .git/config file is invalid,
+. The configuration file is invalid,
. Can not write to .git/config,
. no section was provided,
. the section or key is invalid,
@@ -70,7 +70,7 @@ OPTIONS
Remove all matching lines from .git/config.
-l, --list::
- List all variables set in .git/config.
+ List all variables set in ~/.gitrc or .git/config.
EXAMPLE
diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt
index a5b1a0d..4679aef 100644
--- a/Documentation/git-var.txt
+++ b/Documentation/git-var.txt
@@ -18,8 +18,9 @@ OPTIONS
-------
-l::
Cause the logical variables to be listed. In addition, all the
- variables of the git configuration file .git/config are listed
- as well. (However, the configuration variables listing functionality
+ variables of the git configuration files `~/.gitrc` and `.git/config`
+ are listed as well.
+ (However, the configuration variables listing functionality
is deprecated in favor of `git-repo-config -l`.)
EXAMPLE
diff --git a/Documentation/git.txt b/Documentation/git.txt
index e474bdf..f4e5df5 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -116,7 +116,7 @@ gitlink:git-read-tree[1]::
Reads tree information into the index.
gitlink:git-repo-config[1]::
- Get and set options in .git/config.
+ Get and set git runtime configuration options.
gitlink:git-unpack-objects[1]::
Unpacks objects out of a packed archive.
@@ -473,8 +473,7 @@ gitlink:gitk[1]::
Configuration Mechanism
-----------------------
-Starting from 0.99.9 (actually mid 0.99.8.GIT), `.git/config` file
-is used to hold per-repository configuration options. It is a
+You can adjust the Git behaviour by a configuration file. It is a
simple text file modelled after `.ini` format familiar to some
people. Here is an example:
@@ -496,7 +495,15 @@ #
------------
Various commands read from the configuration file and adjust
-their operation accordingly.
+their operation accordingly. See gitlink:git-repo-config[1]
+for details and list of options.
+
+Git first reads the per-user global configuration from `~/.gitrc`
+and then per-repository configuration from the `.git/config` file.
+Either of these files may be missing; the per-repository configuration
+wins in case of a conflict. Some behaviour can be also tweaked using
+environment variables; in general, they take precedence over configuration
+options.
Identifier Terminology
diff --git a/config.c b/config.c
index 0248c6d..8a98865 100644
--- a/config.c
+++ b/config.c
@@ -312,7 +312,11 @@ int git_config_from_file(config_fn_t fn,
int git_config(config_fn_t fn)
{
- return git_config_from_file(fn, git_path("config"));
+ int ret = 0;
+ if (getenv("HOME"))
+ ret += git_config_from_file(fn, mkpath("%s/.gitrc", getenv("HOME")));
+ ret += git_config_from_file(fn, git_path("config"));
+ return ret;
}
/*
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH] Support for configurable git command aliases
2006-05-28 21:59 ` [PATCH] Support for configurable git command aliases Petr Baudis
@ 2006-05-28 22:57 ` Jakub Narebski
2006-05-29 3:58 ` Jeff King
2006-05-29 2:01 ` Junio C Hamano
1 sibling, 1 reply; 25+ messages in thread
From: Jakub Narebski @ 2006-05-28 22:57 UTC (permalink / raw)
To: git
Petr Baudis wrote:
> Dear diary, on Sat, May 27, 2006 at 02:52:35PM CEST, I got a letter
> where Horst von Brand <vonbrand@inf.utfsm.cl> said that...
>>
>> I don't like this syntax. What other stuff (beside "cmd") would be under
>> "[alias "co"]? Why not simply:
>>
>> [alias]
>> co = commit -a
>> publish = push public.site.com:/pub/scm/my-public-repo
>
> Nice, I like this.
>
> Well, the following isn't exactly the nicest code I have ever written...
> But it seems to work. ;-)
Well, if [alias] would be used also for giving default options for git
commands, e.g.
[alias]
log = log --pretty
(from what Petr "Pasky" Baudis said on IRC, currently on the right side
there should be only true git commands, which eliminates nicely problems
with recursion ;-), it would be better to ensure that aliases are checked
*only* for interactive sessions - otherwise using aliases for default
arguments would/could mess the scripts.
--
Jakub Narebski
Warsaw, Poland
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] Support for configurable git command aliases
2006-05-28 21:59 ` [PATCH] Support for configurable git command aliases Petr Baudis
2006-05-28 22:57 ` Jakub Narebski
@ 2006-05-29 2:01 ` Junio C Hamano
2006-05-29 8:02 ` Petr Baudis
1 sibling, 1 reply; 25+ messages in thread
From: Junio C Hamano @ 2006-05-29 2:01 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
Petr Baudis <pasky@ucw.cz> writes:
>> I don't like this syntax. What other stuff (beside "cmd") would be under
>> "[alias "co"]? Why not simply:
>>
>> [alias]
>> co = commit -a
>> publish = push public.site.com:/pub/scm/my-public-repo
>
> Nice, I like this.
Sorry, I don't. The left hand side of '=' does not allow
anything but alnum and squashes the case. Please stick to
[alias "co"] syntax.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] Support for configurable git command aliases
2006-05-28 22:57 ` Jakub Narebski
@ 2006-05-29 3:58 ` Jeff King
0 siblings, 0 replies; 25+ messages in thread
From: Jeff King @ 2006-05-29 3:58 UTC (permalink / raw)
To: git
On Mon, May 29, 2006 at 12:57:26AM +0200, Jakub Narebski wrote:
> Well, if [alias] would be used also for giving default options for git
> commands, e.g.
>
> [alias]
> log = log --pretty
A funny side effect of that would be that "git log" and "git-log" would
now have completely different defaults (unless the alias mechanism
starts intercepting direct calls to git-*, which seems invasive). I
wonder if it might be simpler to just add
core.defaults.log = "--pretty"
or similar.
-Peff
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] Read configuration also from ~/.gitrc
2006-05-28 22:26 ` [PATCH] Read configuration also from ~/.gitrc Petr Baudis
@ 2006-05-29 7:20 ` Johannes Schindelin
2006-05-29 14:00 ` Jakub Narebski
0 siblings, 1 reply; 25+ messages in thread
From: Johannes Schindelin @ 2006-05-29 7:20 UTC (permalink / raw)
To: Petr Baudis; +Cc: Anand Kumria, git
Hi,
On Mon, 29 May 2006, Petr Baudis wrote:
> diff --git a/config.c b/config.c
> index 0248c6d..8a98865 100644
> --- a/config.c
> +++ b/config.c
> @@ -312,7 +312,11 @@ int git_config_from_file(config_fn_t fn,
>
> int git_config(config_fn_t fn)
> {
> - return git_config_from_file(fn, git_path("config"));
> + int ret = 0;
> + if (getenv("HOME"))
> + ret += git_config_from_file(fn, mkpath("%s/.gitrc", getenv("HOME")));
> + ret += git_config_from_file(fn, git_path("config"));
> + return ret;
> }
>
> /*
But would this not break for the normal case? If you override one key in
the repository's config, with this patch, repo-config will barf. The
normal case is that you do not expect multiple values for the same key.
Your patch reads both ~/.gitrc and $GIT_DIR/config, and if a key has a
value in both (even if they are identical), repo-config will error out.
Further, storing a key will no longer work. This is an obscure side
effect of this patch not caring about storing anything in ~/.gitrc: If you
find the key section (or the key) in ~/.gitrc, the offset will be stored,
_and used on $GIT_DIR/config_!
I agree it is nice to have a global git configuration, but I have it: I
use templates.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] Support for configurable git command aliases
2006-05-29 2:01 ` Junio C Hamano
@ 2006-05-29 8:02 ` Petr Baudis
0 siblings, 0 replies; 25+ messages in thread
From: Petr Baudis @ 2006-05-29 8:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Dear diary, on Mon, May 29, 2006 at 04:01:48AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> said that...
> Petr Baudis <pasky@ucw.cz> writes:
>
> >> I don't like this syntax. What other stuff (beside "cmd") would be under
> >> "[alias "co"]? Why not simply:
> >>
> >> [alias]
> >> co = commit -a
> >> publish = push public.site.com:/pub/scm/my-public-repo
> >
> > Nice, I like this.
>
> Sorry, I don't. The left hand side of '=' does not allow
> anything but alnum and squashes the case.
Does that really matter that much? Perhaps we might support something
like
"!ooOk" = commit -a
(and it will probably not do what the user expects if he sticks
whitespaces in).
> Please stick to [alias "co"] syntax.
That sucks, e.g. because it's alias-specific, and it's inconsistent.
I can't have anything like "cgalias" then.
Let's make some effort to keep the syntax clean...
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] Read configuration also from ~/.gitrc
2006-05-29 7:20 ` Johannes Schindelin
@ 2006-05-29 14:00 ` Jakub Narebski
0 siblings, 0 replies; 25+ messages in thread
From: Jakub Narebski @ 2006-05-29 14:00 UTC (permalink / raw)
To: git
Johannes Schindelin wrote:
> But would this not break for the normal case? If you override one key in
> the repository's config, with this patch, repo-config will barf. The
> normal case is that you do not expect multiple values for the same key.
> Your patch reads both ~/.gitrc and $GIT_DIR/config, and if a key has a
> value in both (even if they are identical), repo-config will error out.
So the patch was to simplistic. Values from user's configuration file
~/.gitrc should be marked, to be overridden by $GIT_DIR/config per
repository configuration file.
> Further, storing a key will no longer work. This is an obscure side
> effect of this patch not caring about storing anything in ~/.gitrc: If you
> find the key section (or the key) in ~/.gitrc, the offset will be stored,
> _and used on $GIT_DIR/config_!
I think that storing a key should (unless new option --user-config or
--global is used) should store it in $GIT_DIR/config file; of course index
has to be found there, and if not found it key should be created. Per
configuration file offsets?
> I agree it is nice to have a global git configuration, but I have it: I
> use templates.
There are system-wide templates. git-init-db(1) doesn't show default
directory for _user_ templates...
And I guess that these are the issues why Junio C Hamano wrote:
> * The 'pu' branch, in addition, has these.
>
> - $HOME/.gitrc (Petr Baudis)
> Read configuration also from ~/.gitrc
>
> * I like this but it breaks the tests big time. Not "next"
> material yet, unfortunately.
--
Jakub Narebski
Warsaw, Poland
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2006-05-29 14:01 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-26 15:28 ~/.git/config ? Anand Kumria
2006-05-26 16:33 ` Timo Hirvonen
2006-05-26 16:37 ` Jakub Narebski
2006-05-26 16:38 ` Petr Baudis
2006-05-26 17:05 ` Timo Hirvonen
2006-05-26 17:11 ` Petr Baudis
2006-05-27 2:36 ` Pavel Roskin
2006-05-27 2:57 ` Petr Baudis
2006-05-27 3:20 ` Linus Torvalds
2006-05-27 3:36 ` Linus Torvalds
2006-05-27 4:43 ` Junio C Hamano
2006-05-27 3:40 ` Jakub Narebski
2006-05-27 9:11 ` Junio C Hamano
2006-05-27 12:52 ` Horst von Brand
2006-05-28 21:59 ` [PATCH] Support for configurable git command aliases Petr Baudis
2006-05-28 22:57 ` Jakub Narebski
2006-05-29 3:58 ` Jeff King
2006-05-29 2:01 ` Junio C Hamano
2006-05-29 8:02 ` Petr Baudis
2006-05-27 8:50 ` ~/.git/config ? Nikolai Weibull
2006-05-27 9:09 ` Timo Hirvonen
2006-05-26 17:38 ` Junio C Hamano
2006-05-28 22:26 ` [PATCH] Read configuration also from ~/.gitrc Petr Baudis
2006-05-29 7:20 ` Johannes Schindelin
2006-05-29 14:00 ` Jakub Narebski
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).