Skip to content
  • Jonathan Nieder's avatar
    ident: do not retrieve default ident when unnecessary · d855e4d3
    Jonathan Nieder authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Avoid a getpwuid() call (which contacts the network if the password
    database is not local), read of /etc/mailname, gethostname() call, and
    reverse DNS lookup if the user has already chosen a name and email
    through configuration, the environment, or the command line.
    
    This should slightly speed up commands like "git commit".  More
    importantly, it improves error reporting when computation of the
    default ident string does not go smoothly.  For example, after
    detecting a problem (e.g., "warning: cannot open /etc/mailname:
    Permission denied") in retrieving the default committer identity:
    
    	touch /etc/mailname;	# as root
    	chmod -r /etc/mailname;	# as root
    	git commit -m 'test commit'
    
    you can squelch the warning while waiting for your sysadmin to fix the
    permissions problem.
    
    	echo '[user] email = me@example.com' >>~/.gitconfig
    
    Inspired-by: default avatarJohannes Sixt <j6t@kdgb.org>
    Signed-off-by: default avatarJonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    d855e4d3