From d5cc2de9ff57d2f6734f6e6e34addc2fae1b5b0e Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 28 Nov 2006 11:27:39 +0100 Subject: ident.c: Trim hint printed when gecos is empty. Also remove asterisks for readability, and suggest use of git-config for easy cut & pasting. Signed-off-by: Han-Wen Nienhuys Signed-off-by: Junio C Hamano --- ident.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ident.c') diff --git a/ident.c b/ident.c index efec97ffd0..e415fd3588 100644 --- a/ident.c +++ b/ident.c @@ -158,12 +158,17 @@ static int copy(char *buf, int size, int offset, const char *src) static const char au_env[] = "GIT_AUTHOR_NAME"; static const char co_env[] = "GIT_COMMITTER_NAME"; static const char *env_hint = -"\n*** Environment problem:\n" +"\n" "*** Your name cannot be determined from your system services (gecos).\n" -"*** You would need to set %s and %s\n" -"*** environment variables; otherwise you won't be able to perform\n" -"*** certain operations because of \"empty ident\" errors.\n" -"*** Alternatively, you can use user.name configuration variable.\n\n"; +"\n" +"Run\n" +"\n" +" git repo-config user.email \"you@email.com\"\n" +" git repo-config user.name \"Your Name\"\n" +"\n" +"To set the identity in this repository.\n" +"Add --global to set your account\'s default\n" +"\n"; static const char *get_ident(const char *name, const char *email, const char *date_str, int error_on_no_name) -- cgit v1.2.1 From a7f196a74650e45ce240754e2caa483752651063 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 17 Dec 2006 03:15:14 -0500 Subject: Default GIT_COMMITTER_NAME to login name in recieve-pack. If GIT_COMMITTER_NAME is not available in receive-pack but reflogs are enabled we would normally die out with an error message asking the user to correct their environment settings. Now that reflogs are enabled by default in (what we guessed to be) non-bare Git repositories this may cause problems for some users who don't have their full name in the gecos field and who don't have access to the remote system to correct the problem. So rather than die()'ing out in receive-pack when we try to log a ref change and have no committer name we default to the username, as obtained from the host's password database. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- ident.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ident.c') diff --git a/ident.c b/ident.c index e415fd3588..d7faba6a70 100644 --- a/ident.c +++ b/ident.c @@ -221,3 +221,18 @@ const char *git_committer_info(int error_on_no_name) getenv("GIT_COMMITTER_DATE"), error_on_no_name); } + +void ignore_missing_committer_name() +{ + /* If we did not get a name from the user's gecos entry then + * git_default_name is empty; so instead load the username + * into it as a 'good enough for now' approximation of who + * this user is. + */ + if (!*git_default_name) { + struct passwd *pw = getpwuid(getuid()); + if (!pw) + die("You don't exist. Go away!"); + strlcpy(git_default_name, pw->pw_name, sizeof(git_default_name)); + } +} -- cgit v1.2.1 From 85023577a8f4b540aa64aa37f6f44578c0c305a3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 19 Dec 2006 14:34:12 -0800 Subject: simplify inclusion of system header files. This is a mechanical clean-up of the way *.c files include system header files. (1) sources under compat/, platform sha-1 implementations, and xdelta code are exempt from the following rules; (2) the first #include must be "git-compat-util.h" or one of our own header file that includes it first (e.g. config.h, builtin.h, pkt-line.h); (3) system headers that are included in "git-compat-util.h" need not be included in individual C source files. (4) "git-compat-util.h" does not have to include subsystem specific header files (e.g. expat.h). Signed-off-by: Junio C Hamano --- ident.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'ident.c') diff --git a/ident.c b/ident.c index d7faba6a70..6ad8fedd60 100644 --- a/ident.c +++ b/ident.c @@ -7,9 +7,6 @@ */ #include "cache.h" -#include -#include - static char git_default_date[50]; static void copy_gecos(struct passwd *w, char *name, int sz) -- cgit v1.2.1