move identity config parsing to ident.c

There's no reason for this to be in config, except that once upon a time all of the config parsing was there. It makes more sense to keep the ident code together. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed May 21, 2012 at 19:09 UTC 9597921b6c173d90359e2cfa4c2e36de8d1554e6
3 files changed +23 -23
cache.h
+1
@@ -899,6 +899,7 @@ extern const char *ident_default_email(void);
899 extern const char *ident_default_date(void);
900 extern const char *git_editor(void);
901 extern const char *git_pager(int stdout_is_tty);
902 +extern int git_ident_config(const char *, const char *, void *);
903
904 struct ident_split {
905 const char *name_begin;
config.c
+1 -23
@@ -762,28 +762,6 @@ static int git_default_core_config(const char *var, const char *value)
762 return 0;
763 }
764
765 -static int git_default_user_config(const char *var, const char *value)
766 -{
767 - if (!strcmp(var, "user.name")) {
768 - if (!value)
769 - return config_error_nonbool(var);
770 - strlcpy(git_default_name, value, sizeof(git_default_name));
771 - user_ident_explicitly_given |= IDENT_NAME_GIVEN;
772 - return 0;
773 - }
774 -
775 - if (!strcmp(var, "user.email")) {
776 - if (!value)
777 - return config_error_nonbool(var);
778 - strlcpy(git_default_email, value, sizeof(git_default_email));
779 - user_ident_explicitly_given |= IDENT_MAIL_GIVEN;
780 - return 0;
781 - }
782 -
783 - /* Add other config variables here and to Documentation/config.txt. */
784 - return 0;
785 -}
786 -
765 static int git_default_i18n_config(const char *var, const char *value)
766 {
767 if (!strcmp(var, "i18n.commitencoding"))
@@ -870,7 +848,7 @@ int git_default_config(const char *var, const char *value, void *dummy)
848 return git_default_core_config(var, value);
849
850 if (!prefixcmp(var, "user."))
873 - return git_default_user_config(var, value);
851 + return git_ident_config(var, value, dummy);
852
853 if (!prefixcmp(var, "i18n."))
854 return git_default_i18n_config(var, value);
ident.c
+21
@@ -388,3 +388,24 @@ int user_ident_sufficiently_given(void)
388 return (user_ident_explicitly_given == IDENT_ALL_GIVEN);
389 #endif
390 }
391 +
392 +int git_ident_config(const char *var, const char *value, void *data)
393 +{
394 + if (!strcmp(var, "user.name")) {
395 + if (!value)
396 + return config_error_nonbool(var);
397 + strlcpy(git_default_name, value, sizeof(git_default_name));
398 + user_ident_explicitly_given |= IDENT_NAME_GIVEN;
399 + return 0;
400 + }
401 +
402 + if (!strcmp(var, "user.email")) {
403 + if (!value)
404 + return config_error_nonbool(var);
405 + strlcpy(git_default_email, value, sizeof(git_default_email));
406 + user_ident_explicitly_given |= IDENT_MAIL_GIVEN;
407 + return 0;
408 + }
409 +
410 + return 0;
411 +}