summaryrefslogtreecommitdiff
path: root/ident.c
AgeCommit message (Collapse)Author
2010-12-20ident: die on bogus date formatJeff King
If the user gives "git commit --date=foobar", we silently ignore the --date flag. We should note the error. This patch puts the fix at the lowest level of fmt_ident, which means it also handles GIT_AUTHOR_DATE=foobar, as well. There are two down-sides to this approach: 1. Technically this breaks somebody doing something like "git commit --date=now", which happened to work because bogus data is the same as "now". Though we do explicitly handle the empty string, so anybody passing an empty variable through the environment will still work. If the error is too much, perhaps it can be downgraded to a warning? 2. The error checking happens _after_ the commit message is written, which can be annoying to the user. We can put explicit checks closer to the beginning of git-commit, but that feels a little hack-ish; suddenly git-commit has to care about how fmt_ident works. Maybe we could simply call fmt_ident earlier? Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-19ident.c: replace fprintf with fputs to suppress compiler warningTarmigan Casebolt
Compiling today's pu gave ... CC ident.o CC levenshtein.o ident.c: In function 'fmt_ident': ident.c:206: warning: format not a string literal and no format arguments CC list-objects.o ... This warning seems to have appeared first in 18e95f279ec6 (ident.c: remove unused variables) which removed additional fprintf arguments. Suppress this warning by using fputs instead of fprintf. Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-17user_ident_sufficiently_given(): refactor the logic to be usable from elsewhereJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-10ident.c: treat $EMAIL as giving user.email identity explicitlyJunio C Hamano
The environment variable EMAIL has been honored since 28a94f8 (Fall back to $EMAIL for missing GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL, 2007-04-28) as the end-user's wish to use the address as the identity. When we use it, we should say we are explicitly given email by the user. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-10ident.c: check explicit identity for name and email separatelyJunio C Hamano
bb1ae3f (commit: Show committer if automatic, 2008-05-04) added a logic to check both name and email were given explicitly by the end user, but it assumed that fmt_ident() is never called before git_default_user_config() is called, which was fragile. The former calls setup_ident() and fills the "default" name and email, so the check in the config parser would have mistakenly said both are given even if only user.name was provided. Make the logic more robust by keeping track of name and email separately. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Santi Béjar <santi@agolina.net>
2010-01-08ident.c: remove unused variablesJunio C Hamano
d5cc2de (ident.c: Trim hint printed when gecos is empty., 2006-11-28) reworded the message used as printf() format and dropped "%s" from it; these two variables that hold the names of GIT_{AUTHOR,COMMITTER}_NAME environment variables haven't been used since then. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-13Suppress warnings from "git var -l"Jonathan Nieder
For scripts using "git var -l" to read all logical variables at once, not all per-variable warnings will be relevant. So suppress them. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-02Add backslash to list of 'crud' characters in real nameLinus Torvalds
We remove crud characters at the beginning and end of real-names so that when we see email addresses like From: "David S. Miller" <davem@davemloft.net> we drop the quotes around the name when we parse that and split it up into name and email. However, the list of crud characters was basically just a random list of common things that are found around names, and it didn't contain the backslash character that some insane scripts seem to use when quoting things. So now the kernel has a number of authors listed like Author: \"Rafael J. Wysocki\ <rjw@sisk.pl> because the author name had started out as From: \"Rafael J. Wysocki\" <rjw@sisk.pl> and the only "crud" character we noticed and removed was the final double-quote at the end. We should probably do better quote removal from names anyway, but this is the minimal obvious patch. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-30Replace uses of "git-var" with "git var"Todd Zullinger
Signed-off-by: Todd Zullinger <tmz@pobox.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-06commit: Show committer if automaticSanti Béjar
To warn the user in case he/she might be using an unintended committer identity. Signed-off-by: Santi Béjar <sbejar@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-09ident.c: reword error message when the user name cannot be determinedSanti Béjar
The "config --global" suggested in the message is a valid one-shot fix, and hopefully one-shot across machines that NFS mounts the home directories. This knowledge can hopefully be reused when you are forced to use git on Windows, but the fix based on GECOS would not be applicable, so it is not such a useful hint to mention the exact reason why the name cannot be determined. Signed-off-by: Santi Béjar <sbejar@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-03Fix grammar nits in documentation and in code comments.Jim Meyering
Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-09Re-fix "builtin-commit: fix --signoff"Junio C Hamano
An earlier fix to the said commit was incomplete; it mixed up the meaning of the flag parameter passed to the internal fmt_ident() function, so this corrects it. git_author_info() and git_committer_info() can be told to issue a warning when no usable user information is found, and optionally can be told to error out. Operations that actually use the information to record a new commit or a tag will still error out, but the caller to leave reflog record will just silently use bogus user information. Not warning on misconfigured user information while writing a reflog entry is somewhat debatable, but it is probably nicer to the users to silently let it pass, because the only information you are losing is who checked out the branch. * git_author_info() and git_committer_info() used to take 1 (positive int) to error out with a warning on misconfiguration; this is now signalled with a symbolic constant IDENT_ERROR_ON_NO_NAME. * These functions used to take -1 (negative int) to warn but continue; this is now signalled with a symbolic constant IDENT_WARN_ON_NO_NAME. * fmt_ident() function implements the above error reporting behaviour common to git_author_info() and git_committer_info(). A symbolic constant IDENT_NO_DATE can be or'ed in to the flag parameter to make it return only the "Name <email@address.xz>". * fmt_name() is a thin wrapper around fmt_ident() that always passes IDENT_ERROR_ON_NO_NAME and IDENT_NO_DATE. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-07Merge branch 'maint'Junio C Hamano
* maint: Change from using email.com to example.com as example domain, as per RFC 2606.
2007-12-07Change from using email.com to example.com as example domain, as per RFC 2606.David Symonds
Signed-off-by: David Symonds <dsymonds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-05Merge branch 'kh/commit'Junio C Hamano
* kh/commit: (33 commits) git-commit --allow-empty git-commit: Allow to amend a merge commit that does not change the tree quote_path: fix collapsing of relative paths Make git status usage say git status instead of git commit Fix --signoff in builtin-commit differently. git-commit: clean up die messages Do not generate full commit log message if it is not going to be used Remove git-status from list of scripts as it is builtin Fix off-by-one error when truncating the diff out of the commit message. builtin-commit.c: export GIT_INDEX_FILE for launch_editor as well. Add a few more tests for git-commit builtin-commit: Include the diff in the commit message when verbose. builtin-commit: fix partial-commit support Fix add_files_to_cache() to take pathspec, not user specified list of files Export three helper functions from ls-files builtin-commit: run commit-msg hook with correct message file builtin-commit: do not color status output shown in the message template file_exists(): dangling symlinks do exist Replace "runstatus" with "status" in the tests t7501-commit: Add test for git commit <file> with dirty index. ...
2007-12-04Simplify crud() in ident.cAlex Riesen
Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-12-03Fix --signoff in builtin-commit differently.Junio C Hamano
Introduce fmt_name() specifically meant for formatting the name and email pair, to add signed-off-by value. This reverts parts of 13208572fbe8838fd8835548d7502202d1f7b21d (builtin-commit: fix --signoff) so that an empty datestamp string given to fmt_ident() by mistake will error out as before. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-23builtin-commit: fix --signoffJohannes Schindelin
The Signed-off-by: line contained a spurious timestamp. The reason was a call to git_committer_info(1), which automatically added the timestamp. Instead, fmt_ident() was taught to interpret an empty string for the date (as opposed to NULL, which still triggers the default behavior) as "do not bother with the timestamp", and builtin-commit.c uses it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-14Improved hint on how to set identitySteffen Prohaska
The first thing we teach in the tutorial is to set the default identity in $HOME/.gitconfig using "git config --global". The suggestion in the error message should match the order, while hinting that per repository identity can later be configured differently. Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-06Prefer EMAIL to username@hostname.Matt Kraai
The environment variable $EMAIL gives a better default of user's preferred e-mail address than the hardcoded "username@hostname", as it is understood by many existing programs. We still honor GIT_*_EMAIL environment variables and user.email configuration variable give them higher precedence, so that the user can override $EMAIL or "username@hostname", as they are likely to be more specific to the context of working on a particular project. Signed-off-by: Matt Kraai <kraai@ftbfs.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06$EMAIL is a last resort fallback, as it's system-wide.Pierre Habouzit
$EMAIL is a system-wide setup that is used for many many many applications. If the git user chose a specific user.email setup, then _this_ should be honoured rather than $EMAIL. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-04-29Fall back to $EMAIL for missing GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAILJosh Triplett
Some other programs get the user's email address from $EMAIL, so fall back to that if we don't have a Git-specific email address. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-15ident.c: Use size_t (instead of int) to store sizesLuiz Fernando N. Capitulino
Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-15ident.c: Use const qualifier for 'struct passwd' parametersLuiz Fernando N. Capitulino
Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-05Rename get_ident() to fmt_ident() and make it available to outsideJunio C Hamano
This makes the functionality of ident.c::get_ident() available to other callers. Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-29[PATCH] Rename git-repo-config to git-config.Tom Prince
Signed-off-by: Tom Prince <tom.prince@ualberta.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-28Don't force everybody to call setup_ident().Junio C Hamano
Back when only handful commands that created commit and tag were the only users of committer identity information, it made sense to explicitly call setup_ident() to pre-fill the default value from the gecos information. But it is much simpler for programs to make the call automatic when get_ident() is called these days, since many more programs want to use the information when updating the reflog. Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-26Allow non-developer to clone, checkout and fetch more easily.Junio C Hamano
The code that uses committer_info() in reflog can barf and die whenever it is asked to update a ref. And I do not think calling ignore_missing_committer_name() upfront like recent receive-pack did in the aplication is a reasonable workaround. What the patch does. - git_committer_info() takes one parameter. It used to be "if this is true, then die() if the name is not available due to bad GECOS, otherwise issue a warning once but leave the name empty". The reason was because we wanted to prevent bad commits from being made by git-commit-tree (and its callers). The value 0 is only used by "git var -l". Now it takes -1, 0 or 1. When set to -1, it does not complain but uses the pw->pw_name when name is not available. Existing 0 and 1 values mean the same thing as they used to mean before. 0 means issue warnings and leave it empty, 1 means barf and die. - ignore_missing_committer_name() and its existing caller (receive-pack, to set the reflog) have been removed. - git-format-patch, to come up with the phoney message ID when asked to thread, now passes -1 to git_committer_info(). This codepath uses only the e-mail part, ignoring the name. It used to barf and die. The other call in the same program when asked to add signed-off-by line based on committer identity still passes 1 to make sure it barfs instead of adding a bogus s-o-b line. - log_ref_write in refs.c, to come up with the name to record who initiated the ref update in the reflog, passes -1. It used to barf and die. The last change means that git-update-ref, git-branch, and commit walker backends can now be used in a repository with reflog by somebody who does not have the user identity required to make a commit. They all used to barf and die. I've run tests and all of them seem to pass, and also tried "git clone" as a user whose GECOS is empty -- git clone works again now (it was broken when reflog was enabled by default). But this definitely needs extra sets of eyeballs. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-20simplify inclusion of system header files.Junio C Hamano
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 <junkio@cox.net>
2006-12-17Default GIT_COMMITTER_NAME to login name in recieve-pack.Shawn O. Pearce
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 <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-29ident.c: Trim hint printed when gecos is empty.Han-Wen Nienhuys
Also remove asterisks for readability, and suggest use of git-config for easy cut & pasting. Signed-off-by: Han-Wen Nienhuys <hanwen@xs4all.nl> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-25Rename safe_strncpy() to strlcpy().Peter Eriksen
This cleans up the use of safe_strncpy() even more. Since it has the same semantics as strlcpy() use this name instead. Also move the definition from inside path.c to its own file compat/strlcpy.c, and use it conditionally at compile time, since some platforms already has strlcpy(). It's included in the same way as compat/setenv.c. Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-17Implement safe_strncpy() as strlcpy() and use it more.Peter Eriksen
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-19Delay "empty ident" errors until they really matter.Junio C Hamano
Previous one warned people upfront to encourage fixing their environment early, but some people just use repositories and git tools read-only without making any changes, and in such a case there is not much point insisting on them having a usable ident. This round attempts to move the error until either "git-var" asks for the ident explicitly or "commit-tree" wants to use it. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-18Make "empty ident" error message a bit more helpful.Junio C Hamano
It appears that some people who did not care about having bogus names in their own commit messages are bitten by the recent change to require a sane environment [*1*]. While it was a good idea to prevent people from using bogus names to create commits and doing sign-offs, the error message is not very informative. This patch attempts to warn things upfront and hint people how to fix their environments. [Footnote] *1* The thread is this one. http://marc.theaimsgroup.com/?t=113868084800004 Especially this message. http://marc.theaimsgroup.com/?m=113932830015032 Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-09Do not allow empty name or email.Junio C Hamano
Instead of silently allowing to create a bogus commit that lacks information by mistake, complain loudly and die. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-29code comments: spellJunio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-22git-var: constness and globalness cleanup.Junio C Hamano
var.c::git_var read function did not have to return writable strings; make it and the functions it points at return const char * instead. ident.c::get_ident() did not need to be global, so make it static. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-21Use sensible domain name (the DNS one) when guessing ident informationPetr Baudis
Currently, the code would use getdomainname() call, which however returns something usually unset and not necessarily related at all to the DNS domain name (it seems to be mostly some scary NIS/YP thing). This patch changes the code to actually use the DNS domain name, which is also what tends to be used in emails, and we aim at emails with our ident code. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-18Remove unused include.Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-15Unlocalized isspace and friendsLinus Torvalds
Do our own ctype.h, just to get the sane semantics: we want locale-independence, _and_ we want the right signed behaviour. Plus we only use a very small subset of ctype.h anyway (isspace, isalpha, isdigit and isalnum). Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-12Use git config file for committer name and email infoLinus Torvalds
This starts using the "user.name" and "user.email" config variables if they exist as the default name and email when committing. This means that you don't have to use the GIT_COMMITTER_EMAIL environment variable to override your email - you can just edit the config file instead. The patch looks bigger than it is because it makes the default name and email information non-static and renames it appropriately. And it moves the common git environment variables into a new library file, so that you can link against libgit.a and get the git environment without having to link in zlib and libcrypt. In short, most of it is renaming and moving, the real change core is just a few new lines in "git_default_config()" that copies the user config values to the new base. It also changes "git-var -l" to list the config variables. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-20Use GECOS field a bit better to produce default human readable name.Junio C Hamano
This updates the default human readable name we generate from GECOS field. We assume the "full-name, followed by additional information separated by commas" format, with an & expanding to the capitalized login name. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-17[PATCH] getdomainname should be usable on SunOS with -lnslJunio C Hamano
Jason Riedy suggests that we should be able to use getdomainname if we properly specify which libraries to link. Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-09Retire support for old environment variables.Junio C Hamano
We have deprecated the old environment variable names for quite a while and now it's time to remove them. Gone are: SHA1_FILE_DIRECTORIES AUTHOR_DATE AUTHOR_EMAIL AUTHOR_NAME COMMIT_AUTHOR_EMAIL COMMIT_AUTHOR_NAME SHA1_FILE_DIRECTORY Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-08[PATCH] Portability fix for Solaris 10/x86Patrick Mauritz
* getdomainname unavailable there. * needs -lsocket for linkage. * needs __EXTENSIONS__ at the beginning of convert-objects.c [JC: I've done this slightly differently from what Patrick originally sent to the list and dropped the bit that deals with installations that has curl header and library at non-default location. I am resisting the slipperly slope called autoconf.] Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-24Replace C99 array initializers with code.Jason Riedy
The only use of C99 array initializers is in ident.c, so just replace it with initializing code. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
2005-07-15[PATCH] ident.c: Disambiguate the error messages in setup_identEric W. Biederman
If your user name is too long it is your sysadmin who hates you not your parents! Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> [ Fixed grammar ] Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-15[PATCH] Move git_author_info and git_commiter_info to ident.cEric W. Biederman
Moving these functions allows all of the logic for figuring out what these values are to be shared between programs. Signed-off-by: Linus Torvalds <torvalds@osdl.org>