user.default: New config to prevent using the default values for user.*
PATCH 1/1 user.default: New config to prevent using the default values for user.*
Useful when you want a different email/name for each repository
--- Documentation/config.txt | 5 +++++ cache.h | 1 + config.c | 5 +++++ environment.c | 1 + ident.c | 6 +++--- 5 files changed, 15 insertions(+), 3 deletions(-)
Documentation/config.txt +5 -0
@@ -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
cache.h +1 -0
@@ -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;
config.c +5 -0
@@ -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);
environment.c +1 -0
@@ -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 ;
ident.c +3 -3
@@ -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"
Signature · 1 line
1.5.4.3.447.gc95b3.dirty
Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
Documentation/config.txt url.<base>.insteadOf:: · line 918
Quoted 8 lines
Documentation/config.txt +2
-0@@ -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
Documentation/config.txt static const char au_env[] = "GIT_AUTHOR_NAME"; · line 174
Quoted 6 lines
Documentation/config.txt +1
-1@@ -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?
Quoted 10 lines · Alex Riesen
Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
ident.c static const char au_env[] = "GIT_AUTHOR_NAME"; · line 174
Quoted 6 lines
ident.c +1
-1@@ -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
Santi Béjar, Thu, Mar 06, 2008 22:45:43 +0100:
Quoted 10 lines · Alex Riesen
Quoted 9 lines
Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
Quoted 6 lines
ident.c +1
-1@@ -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"
Quoted 5 lines
Quoted 1 line
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.
Quoted 15 lines · Alex Riesen
Santi Béjar, Thu, Mar 06, 2008 22:45:43 +0100:
Quoted 12 lines · Alex Riesen
Quoted 10 lines
Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
ident.c static const char au_env[] = "GIT_AUTHOR_NAME"; · line 174
Quoted 6 lines
ident.c +1
-1@@ -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?
Quoted 7 lines
Quoted 3 lines
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.
Quoted 2 lines
Others may
be smarter than you.
I don't think this is necessary.
Santi
Hi,
Quoted 20 lines · Santi Béjar
Quoted 19 lines · Alex Riesen
Santi Béjar, Thu, Mar 06, 2008 22:45:43 +0100:
Quoted 15 lines · Alex Riesen
Quoted 10 lines
Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
ident.c static const char au_env[] = "GIT_AUTHOR_NAME"; · line 174
Quoted 6 lines
ident.c +1
-1@@ -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.
Quoted 5 lines
Quoted 3 lines
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.
Quoted 3 lines
Quoted 1 line
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
Quoted 17 lines · Johannes Schindelin
Quoted 15 lines · Santi Béjar
Quoted 14 lines · Alex Riesen
Santi Béjar, Thu, Mar 06, 2008 22:45:43 +0100:
Quoted 12 lines · Alex Riesen
Quoted 10 lines
Santi Béjar, Wed, Mar 05, 2008 20:18:04 +0100:
ident.c static const char au_env[] = "GIT_AUTHOR_NAME"; · line 174
Quoted 6 lines
ident.c +1
-1@@ -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?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
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.
Hi,
Quoted 8 lines · Junio C Hamano
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
Quoted 16 lines · Santi Béjar
Useful when you want a different email/name for each repository
Signed-off-by Santi Béjar <[email protected]>--- Documentation/config.txt | 5 +++++ cache.h | 1 + config.c | 5 +++++ environment.c | 1 + ident.c | 6 +++--- 5 files changed, 15 insertions(+), 3 deletions(-)Documentation/config.txt +0
-0
Documentation/config.txt url.<base>.insteadOf:: · line 918
Quoted 5 lines
Documentation/config.txt +2
-0@@ -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
Documentation/config.txt url.<base>.insteadOf:: · line 921
Quoted 3 lines
Documentation/config.txt +3
-0+ 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
Quoted 20 lines · Jon Loeliger
Quoted 19 lines · Santi Béjar
Useful when you want a different email/name for each repository
Signed-off-by Santi Béjar <[email protected]>--- Documentation/config.txt | 5 +++++ cache.h | 1 + config.c | 5 +++++ environment.c | 1 + ident.c | 6 +++--- 5 files changed, 15 insertions(+), 3 deletions(-)Documentation/config.txt +0
-0@@ -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.
Quoted 5 lines
Documentation/config.txt url.<base>.insteadOf:: · line 918
Quoted 2 lines
Documentation/config.txt +2
-0+user.default:: + If false the defaults values for user.email and user.name are nots/defaults/default
Thanks
Quoted 9 lines
Documentation/config.txt url.<base>.insteadOf:: · line 921
Quoted 4 lines
Documentation/config.txt +3
-0+ 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
Documentation/config.txt url.<base>.insteadOf:: · line 921
Quoted 5 lines · Santi Béjar
Documentation/config.txt +5
-0+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.
Quoted 11 lines · Junio C Hamano
Documentation/config.txt url.<base>.insteadOf:: · line 921
Quoted 5 lines · Santi Béjar
Documentation/config.txt +5
-0+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?
Quoted 4 lines
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
Quoted 9 lines · Santi Béjar
Quoted 4 lines · Junio C Hamano
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'
Quoted 1 line
.git/config" in that hook, for example.
Quoted 10 lines · Junio C Hamano
Quoted 8 lines · Santi Béjar
Quoted 4 lines · Junio C Hamano
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?
Quoted 5 lines
Quoted 2 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'
Quoted 1 line
.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
Quoted 9 lines · Santi Béjar
Quoted 5 lines
Quoted 2 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'
Quoted 1 line
.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?
Quoted 9 lines · Junio C Hamano
Quoted 6 lines · Santi Béjar
Quoted 5 lines
Quoted 2 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'
Quoted 1 line
.git/config" in that hook, for example.
Quoted 8 lines
Quoted 3 lines
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
Quoted 21 lines · Santi Béjar
Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Santi Béjar
Quoted 5 lines
Quoted 2 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'
Quoted 1 line
.git/config" in that hook, for example.
Quoted 8 lines
Quoted 3 lines
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.
Quoted 7 lines
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 addand 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.
Quoted 34 lines · Junio C Hamano
Quoted 21 lines · Santi Béjar
Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Santi Béjar
Quoted 5 lines
Quoted 2 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'
Quoted 1 line
.git/config" in that hook, for example.
Quoted 8 lines
Quoted 3 lines
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.
Quoted 7 lines
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:
Quoted 8 lines
$ mkdir -p /var/tmp/junk && cd /var/tmp/junk $ git init$ echo '[user] name' >>.git/config $ >foo $ git addand tell me what you see.
Every single command fails because it no longer a valid git repository.
Quoted 4 lines
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
Quoted 1 line · Santi Béjar
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*
Quoted 10 lines · Daniel Barkalow
Quoted 1 line · Santi Béjar
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
Hi,
Documentation/config.txt url.<base>.insteadOf:: · line 921
Quoted 13 lines · Santi Béjar
Documentation/config.txt +5
-0@@ -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...
ident.c static void setup_ident(void) · line 81
Quoted 13 lines
ident.c +1
-1@@ -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
Documentation/config.txt url.<base>.insteadOf:: · line 921
Quoted 7 lines · Santi Béjar
Useful when you want a different email/name for each repository
Documentation/config.txt +5
-0+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.
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
Quoted 5 lines · Jakub Narebski
Quoted 1 line · Santi Béjar
Useful when you want a different email/name for each repository
Quoted 10 lines
Documentation/config.txt url.<base>.insteadOf:: · line 921
Quoted 5 lines
Documentation/config.txt +5
-0+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