* Multiple user.name and user.email (possible feature request)
@ 2010-04-18 9:12 Eli Barzilay
2010-04-18 18:16 ` Steven Michalske
0 siblings, 1 reply; 7+ messages in thread
From: Eli Barzilay @ 2010-04-18 9:12 UTC (permalink / raw)
To: git
Is there a way to have *no* default or some invalid default for the
name/email -- something that will make git refuse to create a commit?
For example, I'd be happy if I could put this in my global config:
[user]
name = "Eli Barzilay"
email = "-"
and then have git barf at me when I try to commit with these settings,
since I prefer being forced to set the appropriate address for each
repository rather than deal with the alternative confusion (or just
accepting the limitations and always using the same name/email).
[When I tried to see if it's possible I was surprised to see that git
happily creates commits for "- <->" and even " <>".]
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Multiple user.name and user.email (possible feature request)
2010-04-18 9:12 Multiple user.name and user.email (possible feature request) Eli Barzilay
@ 2010-04-18 18:16 ` Steven Michalske
2010-04-18 18:37 ` Jeff King
0 siblings, 1 reply; 7+ messages in thread
From: Steven Michalske @ 2010-04-18 18:16 UTC (permalink / raw)
To: Eli Barzilay; +Cc: git
On Apr 18, 2010, at 2:12 AM, Eli Barzilay wrote:
> Is there a way to have *no* default or some invalid default for the
> name/email -- something that will make git refuse to create a commit?
>
> For example, I'd be happy if I could put this in my global config:
>
> [user]
> name = "Eli Barzilay"
> email = "-"
>
> and then have git barf at me when I try to commit with these settings,
> since I prefer being forced to set the appropriate address for each
> repository rather than deal with the alternative confusion (or just
> accepting the limitations and always using the same name/email).
Eli,
Just set the variable in the repository, not the global config.
i.e. drop the --global flag. So, in your repository:
git config user.email "that-repos-config"
I have three different email address for different repositories on my
computer. I have my global config set with my most common address,
and the repositories with the less common email set locally in the
repository.
Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Multiple user.name and user.email (possible feature request)
2010-04-18 18:16 ` Steven Michalske
@ 2010-04-18 18:37 ` Jeff King
2010-04-18 18:43 ` Sverre Rabbelier
0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2010-04-18 18:37 UTC (permalink / raw)
To: Steven Michalske; +Cc: Eli Barzilay, git
On Sun, Apr 18, 2010 at 11:16:34AM -0700, Steven Michalske wrote:
> >For example, I'd be happy if I could put this in my global config:
> >
> > [user]
> > name = "Eli Barzilay"
> > email = "-"
> >
> >and then have git barf at me when I try to commit with these settings,
> >since I prefer being forced to set the appropriate address for each
> >repository rather than deal with the alternative confusion (or just
> >accepting the limitations and always using the same name/email).
>
> Just set the variable in the repository, not the global config.
I think the key is that he wants git to barf if he forgets to set the
repo-only config, instead of quietly using the global config.
Sine 1.7.0, git will complain loudly if you simply don't have your
identity set at all. There is no way to make it actually refuse the
commit, but the warning is quite gigantic and hard to miss:
$ git config --global --unset user.name
$ git config --global --unset user.email
$ git commit -m foo
[master 7c2a927] foo
Committer: Jeff King <peff@c-71-185-130-222.hsd1.va.comcast.net>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name Your Name
git config --global user.email you@example.com
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name <you@example.com>'
1 files changed, 1 insertions(+), 0 deletions(-)
So I expect that will serve Eli's purpose.
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Multiple user.name and user.email (possible feature request)
2010-04-18 18:37 ` Jeff King
@ 2010-04-18 18:43 ` Sverre Rabbelier
2010-04-18 18:55 ` Jeff King
0 siblings, 1 reply; 7+ messages in thread
From: Sverre Rabbelier @ 2010-04-18 18:43 UTC (permalink / raw)
To: Jeff King; +Cc: Steven Michalske, Eli Barzilay, git
Heya,
On Sun, Apr 18, 2010 at 20:37, Jeff King <peff@peff.net> wrote:
> So I expect that will serve Eli's purpose.
If it does not, would a pre-commit hook work? If he sets some
recognizable string (such as not setting it) as email and install a
hook that barfs if it sees that?
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Multiple user.name and user.email (possible feature request)
2010-04-18 18:43 ` Sverre Rabbelier
@ 2010-04-18 18:55 ` Jeff King
2010-04-18 20:11 ` Eli Barzilay
0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2010-04-18 18:55 UTC (permalink / raw)
To: Sverre Rabbelier; +Cc: Steven Michalske, Eli Barzilay, git
On Sun, Apr 18, 2010 at 08:43:11PM +0200, Sverre Rabbelier wrote:
> On Sun, Apr 18, 2010 at 20:37, Jeff King <peff@peff.net> wrote:
> > So I expect that will serve Eli's purpose.
>
> If it does not, would a pre-commit hook work? If he sets some
> recognizable string (such as not setting it) as email and install a
> hook that barfs if it sees that?
Yeah, that could work. It would do what he wants, but he would have to
have the hook set up. Which means he either needs to remember to
configure it in each repository (at which point he could just remember
to configure his identity), or he needs to point to a special init
template directory with the hook.
I think setting init.templatedir or GIT_TEMPLATE_DIR in the environment
would accomplish the latter.
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Multiple user.name and user.email (possible feature request)
2010-04-18 18:55 ` Jeff King
@ 2010-04-18 20:11 ` Eli Barzilay
2010-04-18 20:53 ` Eli Barzilay
0 siblings, 1 reply; 7+ messages in thread
From: Eli Barzilay @ 2010-04-18 20:11 UTC (permalink / raw)
To: Sverre Rabbelier, Jeff King, Steven Michalske; +Cc: git
On Apr 18, Steven Michalske wrote:
>
> I have three different email address for different repositories on my
> computer. I have my global config set with my most common address,
> and the repositories with the less common email set locally in the
> repository.
(As already guessed) I really do want it to error instead of guessing.
My problem is that I'm very often checking out trees of one project
(and starting from today that svn-checkout has been replaced by a git
clone), and I will definitely get confused. (It seems to me that this
is a common source of problems, leading to much flammage.)
On Apr 18, Jeff King wrote:
>
> Sine 1.7.0, git will complain loudly if you simply don't have your
> identity set at all. There is no way to make it actually refuse the
> commit, but the warning is quite gigantic and hard to miss:
> [...]
> So I expect that will serve Eli's purpose.
Well, that would get closer, but I'd really prefer if there was a
do-not-use-me value I could set. But in any case, even this is not
working for me -- digging through my environment, I found that I have
EMAIL set to my email, and so git guesses my name and doesn't produce
that huge response.
Worse, if I set up
[user]
name = ""
email = ""
in my ~/.gitconfig (and make sure that I don't have EMAIL set), then
git still guesses the values -- without any warning.
On Apr 18, Jeff King wrote:
> On Sun, Apr 18, 2010 at 08:43:11PM +0200, Sverre Rabbelier wrote:
> >
> > If it does not, would a pre-commit hook work? If he sets some
> > recognizable string (such as not setting it) as email and install
> > a hook that barfs if it sees that?
>
> Yeah, that could work. It would do what he wants, but he would have
> to have the hook set up. Which means he either needs to remember to
> configure it in each repository (at which point he could just
> remember to configure his identity), or he needs to point to a
> special init template directory with the hook.
>
> I think setting init.templatedir or GIT_TEMPLATE_DIR in the
> environment would accomplish the latter.
Yes, that sounds like it will work, and I'll do that. But in general
this well beyond what most people would do. If it was done as I
suggested (actually, how I thought it would behave), then this whole
thing would be easy even for people who are afraid of shell
programming...
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Multiple user.name and user.email (possible feature request)
2010-04-18 20:11 ` Eli Barzilay
@ 2010-04-18 20:53 ` Eli Barzilay
0 siblings, 0 replies; 7+ messages in thread
From: Eli Barzilay @ 2010-04-18 20:53 UTC (permalink / raw)
To: Sverre Rabbelier, Jeff King, Steven Michalske, git
On Apr 18, Eli Barzilay wrote:
> On Apr 18, Jeff King wrote:
> > I think setting init.templatedir or GIT_TEMPLATE_DIR in the
> > environment would accomplish the latter.
>
> Yes, that sounds like it will work, and I'll do that.
... when 1.7.1 is out. That's probably enough time for me to make a
mistake.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-04-18 20:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-18 9:12 Multiple user.name and user.email (possible feature request) Eli Barzilay
2010-04-18 18:16 ` Steven Michalske
2010-04-18 18:37 ` Jeff King
2010-04-18 18:43 ` Sverre Rabbelier
2010-04-18 18:55 ` Jeff King
2010-04-18 20:11 ` Eli Barzilay
2010-04-18 20:53 ` Eli Barzilay
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).