threads / patch / 12523

patchuser.default: New config to prevent using the default values for user.*

Subject: [PATCH] user.default: New config to prevent using the default values for user.*

## tl;dr

23 messages between Mar 5, 2008 and Mar 8, 2008. Diffs are folded; open one to read it.

replies: 22people: 7as markdown or json

Santi Béjar· Mar 5, 2008, 19:18 UTC · lore
Useful when you want a different email/name for each repository
Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
 Documentation/config.txt |    5 +++++
 cache.h                  |    1 +
 config.c                 |    5 +++++
 environment.c            |    1 +
 ident.c                  |    6 +++---
 5 files changed, 15 insertions(+), 3 deletions(-)
Show changes to 5 files +15 −3

Documentation/config.txt, cache.h, config.c, environment.c, ident.c

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 4027726..d7e5b6d 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -914,6 +914,11 @@ url.<base>.insteadOf::
 	never-before-seen repository on the site.  When more than one
 	insteadOf strings match a given URL, the longest match is used.
 
+user.default::
+	If false the defaults values for user.email and user.name are not
+	used. Useful when you want a different email/name for each
+	repository, normally set in the global config file.
+
 user.email::
 	Your email address to be recorded in any newly created commits.
 	Can be overridden by the 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_EMAIL', and
diff --git a/cache.h b/cache.h
index e230302..70f08d0 100644
--- a/cache.h
+++ b/cache.h
@@ -703,6 +703,7 @@ extern int config_error_nonbool(const char *);
 #define MAX_GITNAME (1000)
 extern char git_default_email[MAX_GITNAME];
 extern char git_default_name[MAX_GITNAME];
+extern int default_ident;
 
 extern const char *git_commit_encoding;
 extern const char *git_log_output_encoding;
diff --git a/config.c b/config.c
index 0624494..ea1fa71 100644
--- a/config.c
+++ b/config.c
@@ -445,6 +445,11 @@ int git_default_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "user.default")) {
+		default_ident = git_config_bool(var, value);
+		return 0;
+	}
+
 	if (!strcmp(var, "i18n.commitencoding"))
 		return git_config_string(&git_commit_encoding, var, value);
 
diff --git a/environment.c b/environment.c
index 6739a3f..8e252e2 100644
--- a/environment.c
+++ b/environment.c
@@ -11,6 +11,7 @@
 
 char git_default_email[MAX_GITNAME];
 char git_default_name[MAX_GITNAME];
+int default_ident = 1;
 int trust_executable_bit = 1;
 int quote_path_fully = 1;
 int has_symlinks = 1;
diff --git a/ident.c b/ident.c
index b839dcf..0f62a94 100644
--- a/ident.c
+++ b/ident.c
@@ -75,7 +75,7 @@ static void setup_ident(void)
 	struct passwd *pw = NULL;
 
 	/* Get the name ("gecos") */
-	if (!git_default_name[0]) {
+	if (!git_default_name[0] && default_ident) {
 		pw = getpwuid(getuid());
 		if (!pw)
 			die("You don't exist. Go away!");
@@ -88,7 +88,7 @@ static void setup_ident(void)
 		if (email && email[0])
 			strlcpy(git_default_email, email,
 				sizeof(git_default_email));
-		else {
+		else if (default_ident) {
 			if (!pw)
 				pw = getpwuid(getuid());
 			if (!pw)
@@ -171,7 +171,7 @@ static const char au_env[] = "GIT_AUTHOR_NAME";
 static const char co_env[] = "GIT_COMMITTER_NAME";
 static const char *env_hint =
 "\n"
-"*** Your name cannot be determined from your system services (gecos).\n"
+"*** Your name cannot be determined.\n"
 "\n"
 "Run\n"
 "\n"
-- 
1.5.4.3.447.gc95b3.dirty
Jon Loeliger· Mar 5, 2008, 19:54 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

Santi Béjar wrote:
Show 21 quoted lines
> Useful when you want a different email/name for each repository
> 
> Signed-off-by: Santi Béjar <sbejar@gmail.com>
> ---
>  Documentation/config.txt |    5 +++++
>  cache.h                  |    1 +
>  config.c                 |    5 +++++
>  environment.c            |    1 +
>  ident.c                  |    6 +++---
>  5 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 4027726..d7e5b6d 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -914,6 +914,11 @@ url.<base>.insteadOf::
>  	never-before-seen repository on the site.  When more than one
>  	insteadOf strings match a given URL, the longest match is used.
>  
> +user.default::
> +	If false the defaults values for user.email and user.name are not
s/defaults/default
> +	used. Useful when you want a different email/name for each
> +	repository, normally set in the global config file.
> +

You already _can_ have a different email/name for each repository, right? Isn't the issue that you want to _force_ each repository to explicitly have these values set?

jdl
Santi Béjar· Mar 5, 2008, 20:36 UTC · re: Jon Loeliger · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Wed, Mar 5, 2008 at 8:54 PM, Jon Loeliger <jdl@freescale.com> wrote:
Show 25 quoted lines
> Santi Béjar wrote:
>  > Useful when you want a different email/name for each repository
>  >
>  > Signed-off-by: Santi Béjar <sbejar@gmail.com>
>  > ---
>  >  Documentation/config.txt |    5 +++++
>  >  cache.h                  |    1 +
>  >  config.c                 |    5 +++++
>  >  environment.c            |    1 +
>  >  ident.c                  |    6 +++---
>  >  5 files changed, 15 insertions(+), 3 deletions(-)
>  >
>  > diff --git a/Documentation/config.txt b/Documentation/config.txt
>  > index 4027726..d7e5b6d 100644
>  > --- a/Documentation/config.txt
>  > +++ b/Documentation/config.txt
>  > @@ -914,6 +914,11 @@ url.<base>.insteadOf::
>  >       never-before-seen repository on the site.  When more than one
>  >       insteadOf strings match a given URL, the longest match is used.
>  >
>  > +user.default::
>  > +     If false the defaults values for user.email and user.name are not
>
>  s/defaults/default
>
Thanks
Show 9 quoted lines
>
>  > +     used. Useful when you want a different email/name for each
>  > +     repository, normally set in the global config file.
>  > +
>
>  You already _can_ have a different email/name for each
>  repository, right?  Isn't the issue that you want to _force_
>  each repository to explicitly have these values set?
>

Maybe: Useful when you want a different email/name for each repository, so you can set this in the global config file and then you are force to set the user.email and user.name in each repository.

(sorry for my non-native english)
Thanks
Santi
Johannes Schindelin· Mar 5, 2008, 20:11 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

Hi,
On Wed, 5 Mar 2008, Santi Béjar wrote:
Show 13 quoted lines
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 4027726..d7e5b6d 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -914,6 +914,11 @@ url.<base>.insteadOf::
>  	never-before-seen repository on the site.  When more than one
>  	insteadOf strings match a given URL, the longest match is used.
>  
> +user.default::
> +	If false the defaults values for user.email and user.name are not
> +	used. Useful when you want a different email/name for each
> +	repository, normally set in the global config file.
> +
I have to wonder: why do you set it in global config file the first place?
And the answer...
Show 13 quoted lines
> diff --git a/ident.c b/ident.c
> index b839dcf..0f62a94 100644
> --- a/ident.c
> +++ b/ident.c
> @@ -75,7 +75,7 @@ static void setup_ident(void)
>  	struct passwd *pw = NULL;
>  
>  	/* Get the name ("gecos") */
> -	if (!git_default_name[0]) {
> +	if (!git_default_name[0] && default_ident) {
>  		pw = getpwuid(getuid());
>  		if (!pw)
>  			die("You don't exist. Go away!");

... is here. You are actually not at all talking about the global config file, but the gecos information instead.

Ciao, Dscho

Daniel Barkalow· Mar 5, 2008, 20:21 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Wed, 5 Mar 2008, Santi Béjar wrote:
> Useful when you want a different email/name for each repository

I still think it would be more intuitive if you made it so that setting user.* to nothing was not an error, suppressed picking values up from the system, and led (if not overridden again) to the message telling you how to set them. Is there some reason you decided not to have that be how the user triggers this behavior?

	-Daniel
*This .sig left intentionally blank*
Santi Béjar· Mar 5, 2008, 20:41 UTC · re: Daniel Barkalow · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Wed, Mar 5, 2008 at 9:21 PM, Daniel Barkalow <barkalow@iabervon.org> wrote:
Show 10 quoted lines
> On Wed, 5 Mar 2008, Santi Béjar wrote:
>
>
> > Useful when you want a different email/name for each repository
>
>  I still think it would be more intuitive if you made it so that setting
>  user.* to nothing was not an error, suppressed picking values up from the
>  system, and led (if not overridden again) to the message telling you how
>  to set them. Is there some reason you decided not to have that be how the
>  user triggers this behavior?

I first tried this way, but when I was writing the documentation I found it more clean and easy if it was a separate config.

Santi
Alex Riesen· Mar 5, 2008, 20:44 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
Show 8 quoted lines
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -914,6 +914,11 @@ url.<base>.insteadOf::
>  	never-before-seen repository on the site.  When more than one
>  	insteadOf strings match a given URL, the longest match is used.
>  
> +user.default::
> +	If false the defaults values for user.email and user.name are not
"If false the default values"... An "s" in "default" was superflous
Show 6 quoted lines
> @@ -171,7 +171,7 @@ static const char au_env[] = "GIT_AUTHOR_NAME";
>  static const char co_env[] = "GIT_COMMITTER_NAME";
>  static const char *env_hint =
>  "\n"
> -"*** Your name cannot be determined from your system services (gecos).\n"
> +"*** Your name cannot be determined.\n"
Why not?
Santi Béjar· Mar 6, 2008, 21:45 UTC · re: Alex Riesen · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Wed, Mar 5, 2008 at 9:44 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
Show 10 quoted lines
> Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
>
>  > @@ -171,7 +171,7 @@ static const char au_env[] = "GIT_AUTHOR_NAME";
>  >  static const char co_env[] = "GIT_COMMITTER_NAME";
>  >  static const char *env_hint =
>  >  "\n"
>  > -"*** Your name cannot be determined from your system services (gecos).\n"
>  > +"*** Your name cannot be determined.\n"
>
>  Why not?

Is this important? Or in another way, is this useful? The important thing is how you can fix it. But others think otherwise I'll change it to explain the reason.

Santi
Alex Riesen· Mar 7, 2008, 16:41 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

Santi Béjar, Thu, Mar 06, 2008 22:45:43 +0100:
Show 15 quoted lines
> On Wed, Mar 5, 2008 at 9:44 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
> > Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
> >
> >  > @@ -171,7 +171,7 @@ static const char au_env[] = "GIT_AUTHOR_NAME";
> >  >  static const char co_env[] = "GIT_COMMITTER_NAME";
> >  >  static const char *env_hint =
> >  >  "\n"
> >  > -"*** Your name cannot be determined from your system services (gecos).\n"
> >  > +"*** Your name cannot be determined.\n"
> >
> >  Why not?
> 
> Is this important? Or in another way, is this useful? The important
> thing is how you can fix it. But others think otherwise I'll change it
> to explain the reason.

It is precise explanation of what happened. It could be a hint to fix gecos field to someone. It is considered useful not to hide information, even if you have no idea of how useful it is. Others may be smarter than you.

It could be shortened, thopugh. Maybe remove the asterisks, and replace "from your system services (gecos)" with a shorter (but precise) information.

Santi Béjar· Mar 8, 2008, 00:13 UTC · re: Alex Riesen · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Fri, Mar 7, 2008 at 5:41 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
Show 22 quoted lines
> Santi Béjar, Thu, Mar 06, 2008 22:45:43 +0100:
>
>
> > On Wed, Mar 5, 2008 at 9:44 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
>  > > Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
>  > >
>  > >  > @@ -171,7 +171,7 @@ static const char au_env[] = "GIT_AUTHOR_NAME";
>  > >  >  static const char co_env[] = "GIT_COMMITTER_NAME";
>  > >  >  static const char *env_hint =
>  > >  >  "\n"
>  > >  > -"*** Your name cannot be determined from your system services (gecos).\n"
>  > >  > +"*** Your name cannot be determined.\n"
>  > >
>  > >  Why not?
>  >
>  > Is this important? Or in another way, is this useful? The important
>  > thing is how you can fix it. But others think otherwise I'll change it
>  > to explain the reason.
>
>  It is precise explanation of what happened. It could be a hint to fix
>  gecos field to someone. It is considered useful not to hide
>  information, even if you have no idea of how useful it is.
I'll wait for others to comment.
>  Others may
>  be smarter than you.
I don't think this is necessary.
Santi
Johannes Schindelin· Mar 8, 2008, 01:24 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

Hi,
On Sat, 8 Mar 2008, Santi Béjar wrote:
Show 25 quoted lines
> On Fri, Mar 7, 2008 at 5:41 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
> > Santi Béjar, Thu, Mar 06, 2008 22:45:43 +0100:
> >
> >
> > > On Wed, Mar 5, 2008 at 9:44 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
> >  > > Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
> >  > >
> >  > >  > @@ -171,7 +171,7 @@ static const char au_env[] = "GIT_AUTHOR_NAME";
> >  > >  >  static const char co_env[] = "GIT_COMMITTER_NAME";
> >  > >  >  static const char *env_hint =
> >  > >  >  "\n"
> >  > >  > -"*** Your name cannot be determined from your system services (gecos).\n"
> >  > >  > +"*** Your name cannot be determined.\n"
> >  > >
> >  > >  Why not?
> >  >
> >  > Is this important? Or in another way, is this useful? The important
> >  > thing is how you can fix it. But others think otherwise I'll change it
> >  > to explain the reason.
> >
> >  It is precise explanation of what happened. It could be a hint to fix
> >  gecos field to someone. It is considered useful not to hide
> >  information, even if you have no idea of how useful it is.
> 
> I'll wait for others to comment.

I thought I asked why you had to remove the comment (which seems not to have a proper reasoning in the commit message), but maybe I did not.

So here it is in writing: I agree with Alex on the criticism on this part of your patch.

> >  Others may be smarter than you.
> 
> I don't think this is necessary.
It is not necessary that others may be smarter than you, alright.

Hth, Dscho

Junio C Hamano· Mar 8, 2008, 02:08 UTC · re: Johannes Schindelin · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 24 quoted lines
> On Sat, 8 Mar 2008, Santi Béjar wrote:
>
>> On Fri, Mar 7, 2008 at 5:41 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
>> > Santi Béjar, Thu, Mar 06, 2008 22:45:43 +0100:
>> >
>> > > On Wed, Mar 5, 2008 at 9:44 PM, Alex Riesen <raa.lkml@gmail.com> wrote:
>> >  > > Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
>> >  > >
>> >  > >  > @@ -171,7 +171,7 @@ static const char au_env[] = "GIT_AUTHOR_NAME";
>> >  > >  >  static const char co_env[] = "GIT_COMMITTER_NAME";
>> >  > >  >  static const char *env_hint =
>> >  > >  >  "\n"
>> >  > >  > -"*** Your name cannot be determined from your system services (gecos).\n"
>> >  > >  > +"*** Your name cannot be determined.\n"
>> >  > >
>> >  > >  Why not?
>> >  >
>> >  > Is this important? Or in another way, is this useful? The important
>> >  > thing is how you can fix it. But others think otherwise I'll change it
>> >  > to explain the reason.
>> >
>> >  It is precise explanation of what happened. It could be a hint to fix
>> >  gecos field to someone. It is considered useful not to hide
>> >  information, even if you have no idea of how useful it is.

I'd agree with that reasoning on one condition, that is, msysgit folks would adjust this to whatever gecos equivalent is called in the Windows world ;-).

I do not personally think this part of the patch is so bad to waste your brain cells and time arguing about. I would even suggest removing the whole "cannot be determined" and just say "Please tell me who you are."

Yes, if you tell people that a lacking GECOS is the underlying reason that you are getting this message, it would hint them an alternative solution of talking to their sysadmin to get it fixed, and that one-shot fix will last for all repositories on that machine (and machines that consult the same NIS/LDAP for name information). However, the "config --global" suggested in that message is also a valid one-shot fix, and hopefully one-shot across machines that NFS mounts the home directories. The latter knowledge can hopefully be reused when you are forced to use git on Windows, but the fix based on GECOS would probably not.

So I'd even argue that Santi's change to the message is an improvement that removes geekspeak that is not particularly useful to the end user in this context.

However, I would also say that this message improvement does not belong to user.default or whatever the configuration variable is called in this round of proposal. It should be a separate patch, and it would be a much easier sell than the rest of the patch series.

Johannes Schindelin· Mar 8, 2008, 02:22 UTC · re: Junio C Hamano · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

Hi,
On Fri, 7 Mar 2008, Junio C Hamano wrote:
Show 8 quoted lines
> So I'd even argue that Santi's change to the message is an improvement 
> that removes geekspeak that is not particularly useful to the end user 
> in this context.
> 
> However, I would also say that this message improvement does not belong 
> to user.default or whatever the configuration variable is called in this 
> round of proposal.  It should be a separate patch, and it would be a 
> much easier sell than the rest of the patch series.

That was the whole point of Alex' criticism. I was slightly irritated that his comments elicited a criticism of their own.

Sorry for that, Dscho

Jakub Narebski· Mar 5, 2008, 21:01 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

Santi Béjar <sbejar@gmail.com> writes:
> Useful when you want a different email/name for each repository
Show 5 quoted lines
> +user.default::
> +	If false the defaults values for user.email and user.name are not
> +	used. Useful when you want a different email/name for each
> +	repository, normally set in the global config file.
> +

Wouldn't it be better to use user.noDefault, or user.explicit, or user.dontGuess... user.default seems like place to provide some default value, not place to decide if there should be some fallback default values or not.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Santi Béjar· Mar 5, 2008, 22:35 UTC · re: Jakub Narebski · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Wed, Mar 5, 2008 at 10:01 PM, Jakub Narebski <jnareb@gmail.com> wrote:
Show 15 quoted lines
> Santi Béjar <sbejar@gmail.com> writes:
>
>  > Useful when you want a different email/name for each repository
>
>
> > +user.default::
>  > +     If false the defaults values for user.email and user.name are not
>  > +     used. Useful when you want a different email/name for each
>  > +     repository, normally set in the global config file.
>  > +
>
>  Wouldn't it be better to use user.noDefault, or user.explicit,
>  or user.dontGuess... user.default seems like place to provide
>  some default value, not place to decide if there should be some
>  fallback default values or not.
Make sense. I prefer user.explicit.
Santi
Junio C Hamano· Mar 5, 2008, 21:29 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

Santi Béjar <sbejar@gmail.com> writes:
Show 5 quoted lines
> +user.default::
> +	If false the defaults values for user.email and user.name are not
> +	used. Useful when you want a different email/name for each
> +	repository, normally set in the global config file.
> +

Aren't there other configuration variables that you might want to tweak per repository?

Perhaps you can make git-init run a post-init hook script by default, and have ~/.gitconfig specify the location of it, and have it do whatever custom settings to the per-repository configuration file?

Wouldn't that be a more generally useful thing to do, instead of adding special-purpose configuration variables like this?

If we go that alternate route, I would imagine that we would need to add "--no-post-init" flag to git-init (and probably an environment GIT_NO_POST_INIT) so that git-clone and others that run git-init internally can disable the hook if they want to.

Santi Béjar· Mar 5, 2008, 22:33 UTC · re: Junio C Hamano · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Wed, Mar 5, 2008 at 10:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> Santi Béjar <sbejar@gmail.com> writes:
>
>  > +user.default::
>  > +     If false the defaults values for user.email and user.name are not
>  > +     used. Useful when you want a different email/name for each
>  > +     repository, normally set in the global config file.
>  > +
>
>  Aren't there other configuration variables that you might want
>  to tweak per repository?
>
>  Perhaps you can make git-init run a post-init hook script by
>  default, and have ~/.gitconfig specify the location of it, and
>  have it do whatever custom settings to the per-repository
>  configuration file?

I would still need something to prevent doing a commit without a locally specified name/email.

Santi
Junio C Hamano· Mar 5, 2008, 22:53 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

"Santi Béjar" <sbejar@gmail.com> writes:
Show 9 quoted lines
> On Wed, Mar 5, 2008 at 10:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
>>  Perhaps you can make git-init run a post-init hook script by
>>  default, and have ~/.gitconfig specify the location of it, and
>>  have it do whatever custom settings to the per-repository
>>  configuration file?
>
> I would still need something to prevent doing a commit without a
> locally specified name/email.
Yes, but that something could simply be "echo '[user] name'
>.git/config" in that hook, for example.
Santi Béjar· Mar 5, 2008, 23:23 UTC · re: Junio C Hamano · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Wed, Mar 5, 2008 at 11:53 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> "Santi Béjar" <sbejar@gmail.com> writes:
>
>  > On Wed, Mar 5, 2008 at 10:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
>  >
>
> >>  Perhaps you can make git-init run a post-init hook script by
>  >>  default, and have ~/.gitconfig specify the location of it, and
>  >>  have it do whatever custom settings to the per-repository
>  >>  configuration file?
>  >
>  > I would still need something to prevent doing a commit without a
>  > locally specified name/email.
>
>  Yes, but that something could simply be "echo '[user] name'
>  >.git/config" in that hook, for example.

But I want a different locally specified name in each repository, because I use different emails for different projects (private/work/...).

Santi
Junio C Hamano· Mar 5, 2008, 23:29 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

"Santi Béjar" <sbejar@gmail.com> writes:
Show 9 quoted lines
>>  > I would still need something to prevent doing a commit without a
>>  > locally specified name/email.
>>
>>  Yes, but that something could simply be "echo '[user] name'
>>  >.git/config" in that hook, for example.
>
> But I want a different locally specified name in each repository,
> because I use different emails for different projects
> (private/work/...).

You changed your mind then? You said you wanted to have something that prevents a commit from being made immediately after git-init before per-repo user.name is properly configured. Doesn't that echo achieve that goal?

Santi Béjar· Mar 5, 2008, 23:39 UTC · re: Junio C Hamano · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Thu, Mar 6, 2008 at 12:29 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> "Santi Béjar" <sbejar@gmail.com> writes:
>
>
> >>  > I would still need something to prevent doing a commit without a
>  >>  > locally specified name/email.
>  >>
>  >>  Yes, but that something could simply be "echo '[user] name'
>  >>  >.git/config" in that hook, for example.
>  >
>  > But I want a different locally specified name in each repository,
>  > because I use different emails for different projects
>  > (private/work/...).
>
>  You changed your mind then?  You said you wanted to have something that
>  prevents a commit from being made immediately after git-init before
>  per-repo user.name is properly configured.  Doesn't that echo achieve that
>  goal?

But that was in the context of the initial patch where I said that I wanted different name/emails in each repository.

To summarize, the problem is that I work in different projects (private/work/git/...) using the same account, but I want different identifies (name/email) in each. So I set user.name and user.email in each repository, but when I forget to set them git uses the default ones (userid@hostname.(none)).

Hope I have explained it well.
Santi
Junio C Hamano· Mar 6, 2008, 00:29 UTC · re: Santi Béjar · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

"Santi Béjar" <sbejar@gmail.com> writes:
Show 28 quoted lines
> On Thu, Mar 6, 2008 at 12:29 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> "Santi Béjar" <sbejar@gmail.com> writes:
>>
>> >>  > I would still need something to prevent doing a commit without a
>>  >>  > locally specified name/email.
>>  >>
>>  >>  Yes, but that something could simply be "echo '[user] name'
>>  >>  >.git/config" in that hook, for example.
>>  >
>>  > But I want a different locally specified name in each repository,
>>  > because I use different emails for different projects
>>  > (private/work/...).
>>
>>  You changed your mind then?  You said you wanted to have something that
>>  prevents a commit from being made immediately after git-init before
>>  per-repo user.name is properly configured.  Doesn't that echo achieve that
>>  goal?
>
> But that was in the context of the initial patch where I said that I
> wanted different name/emails in each repository.
>
> To summarize, the problem is that I work in different projects
> (private/work/git/...) using the same account, but I want different
> identifies (name/email) in each. So I set user.name and user.email in
> each repository, but when I forget to set them git uses the default
> ones (userid@hostname.(none)).
>
> Hope I have explained it well.
Try:
        $ mkdir -p /var/tmp/junk && cd /var/tmp/junk
        $ git init
        $ echo '[user] name' >>.git/config
        $ >foo
        $ git add
and tell me what you see.

That's why I gave you the example of setting "[user] name" (notice I did not say [user] name = 'Santi's name for this project') to force you to configure it to whatever you want.

Santi Béjar· Mar 6, 2008, 08:08 UTC · re: Junio C Hamano · lore

Re: [PATCH] user.default: New config to prevent using the default values for user.*

On Thu, Mar 6, 2008 at 1:29 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 42 quoted lines
>
> "Santi Béjar" <sbejar@gmail.com> writes:
>
>  > On Thu, Mar 6, 2008 at 12:29 AM, Junio C Hamano <gitster@pobox.com> wrote:
>  >> "Santi Béjar" <sbejar@gmail.com> writes:
>  >>
>  >> >>  > I would still need something to prevent doing a commit without a
>  >>  >>  > locally specified name/email.
>  >>  >>
>  >>  >>  Yes, but that something could simply be "echo '[user] name'
>  >>  >>  >.git/config" in that hook, for example.
>  >>  >
>  >>  > But I want a different locally specified name in each repository,
>  >>  > because I use different emails for different projects
>  >>  > (private/work/...).
>  >>
>  >>  You changed your mind then?  You said you wanted to have something that
>  >>  prevents a commit from being made immediately after git-init before
>  >>  per-repo user.name is properly configured.  Doesn't that echo achieve that
>  >>  goal?
>  >
>  > But that was in the context of the initial patch where I said that I
>  > wanted different name/emails in each repository.
>  >
>  > To summarize, the problem is that I work in different projects
>  > (private/work/git/...) using the same account, but I want different
>  > identifies (name/email) in each. So I set user.name and user.email in
>  > each repository, but when I forget to set them git uses the default
>  > ones (userid@hostname.(none)).
>  >
>  > Hope I have explained it well.
>
>  Try:
>
>         $ mkdir -p /var/tmp/junk && cd /var/tmp/junk
>         $ git init
>
>         $ echo '[user] name' >>.git/config
>         $ >foo
>         $ git add
>
>  and tell me what you see.
Every single command fails because it no longer a valid git repository.
>
>  That's why I gave you the example of setting "[user] name"
>  (notice I did not say [user] name = 'Santi's name for this project')
>  to force you to configure it to whatever you want.

But then I have to configure in all the repositories, even the ones I do not develop.

Santi

← back to recent threads