git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] user.default: New config to prevent using the default values for user.*
@ 2008-03-05 19:18 Santi Béjar
  2008-03-05 19:54 ` Jon Loeliger
                   ` (5 more replies)
  0 siblings, 6 replies; 23+ messages in thread
From: Santi Béjar @ 2008-03-05 19:18 UTC (permalink / raw)
  To: git; +Cc: Santi Béjar

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
+	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


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2008-03-08  2:23 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-05 19:18 [PATCH] user.default: New config to prevent using the default values for user.* Santi Béjar
2008-03-05 19:54 ` Jon Loeliger
2008-03-05 20:36   ` Santi Béjar
2008-03-05 20:11 ` Johannes Schindelin
2008-03-05 20:21 ` Daniel Barkalow
2008-03-05 20:41   ` Santi Béjar
2008-03-05 20:44 ` Alex Riesen
2008-03-06 21:45   ` Santi Béjar
2008-03-07 16:41     ` Alex Riesen
2008-03-08  0:13       ` Santi Béjar
2008-03-08  1:24         ` Johannes Schindelin
2008-03-08  2:08           ` Junio C Hamano
2008-03-08  2:22             ` Johannes Schindelin
2008-03-05 21:01 ` Jakub Narebski
2008-03-05 22:35   ` Santi Béjar
2008-03-05 21:29 ` Junio C Hamano
2008-03-05 22:33   ` Santi Béjar
2008-03-05 22:53     ` Junio C Hamano
2008-03-05 23:23       ` Santi Béjar
2008-03-05 23:29         ` Junio C Hamano
2008-03-05 23:39           ` Santi Béjar
2008-03-06  0:29             ` Junio C Hamano
2008-03-06  8:08               ` Santi Béjar

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).