git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Santi Béjar" <sbejar@gmail.com>
To: git@vger.kernel.org
Cc: "Santi Béjar" <sbejar@gmail.com>
Subject: [PATCH] user.default: New config to prevent using the default values for user.*
Date: Wed,  5 Mar 2008 20:18:04 +0100	[thread overview]
Message-ID: <1204744684-2043-1-git-send-email-sbejar@gmail.com> (raw)

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


             reply	other threads:[~2008-03-05 19:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-05 19:18 Santi Béjar [this message]
2008-03-05 19:54 ` [PATCH] user.default: New config to prevent using the default values for user.* 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1204744684-2043-1-git-send-email-sbejar@gmail.com \
    --to=sbejar@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).