{"thread":{"id":"11201","subject":"[Misfeature] cloning without configuration fails and returns 0","startedAt":"2007-12-08T22:21:35Z","lastAt":"2007-12-11T11:42:11Z","messageCount":3,"participants":["Benoit Sigoure","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"62435","messageId":"9438BB94-AE9C-4F4E-A4DA-8E2121642736@lrde.epita.fr","threadId":"11201","inReplyTo":null,"subject":"[Misfeature] cloning without configuration fails and returns 0","fromName":"Benoit Sigoure","fromEmail":"tsuna@lrde.epita.fr","sentAt":"2007-12-08T22:21:35Z","receivedAt":"2007-12-08T22:21:35Z","isPatch":false,"sender":{"key":"tsunanet@gmail.com","avatar":"https://avatars.githubusercontent.com/u/128281?v=4"},"body":"Hi,\non a new machine I have access to, I fetched tonight's git master  \n(git version 1.5.3.7.g9758e) and installed it on my account in order  \nto clone one of my projects.  I did not setup anything in my git  \nconfig and stumbled on the following misfeature:\n\n----------------------------------------------------------------------\n$ git clone ssh://login@host/~/path/git/project/.git project\nInitialized empty Git repository in /home/me/git/project/.git/\nPassword:\nremote: Counting objects: 609, done.\nremote: Compressing objects: 100% (465/465), done.\nremote: Total 609 (delta 267), reused 462 (delta 134)\nReceiving objects: 100% (609/609), 1.56 MiB | 63 KiB/s, done.\nResolving deltas: 100% (267/267), done.\n\n*** Your name cannot be determined from your system services (gecos).\n\nRun\n\n   git config --global user.email \"you@example.com\"\n   git config --global user.name \"Your Name\"\n\nto set your account's default identity.\nOmit --global to set the identity only in this repository.\n\nfatal: empty ident  <me@fqdn> not allowed\n[last 11 lines repeated 3 times!]\nfatal: Not a valid object name HEAD\n----------------------------------------------------------------------\n\nNot only the same 11 lines of error message were printed 3 times, but  \nalso the command returned 0!\n\nThis is not user friendly at all.  So I thought I'd point this out on  \nthis ML.\n\nCheers,\n\n-- \nBenoit Sigoure aka Tsuna\nEPITA Research and Development Laboratory\n"},{"id":"62441","messageId":"7vzlwktzzb.fsf@gitster.siamese.dyndns.org","threadId":"11201","inReplyTo":"9438BB94-AE9C-4F4E-A4DA-8E2121642736@lrde.epita.fr","subject":"Re: [Misfeature] cloning without configuration fails and returns 0","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-09T01:32:08Z","receivedAt":"2007-12-09T01:32:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Benoit Sigoure <tsuna@lrde.epita.fr> writes:\n\n> on a new machine I have access to, I fetched tonight's git master (git\n> version 1.5.3.7.g9758e) and installed it on my account in order  to\n> clone one of my projects.  I did not setup anything in my git config\n> and stumbled on the following misfeature:\n\nThis is not a misfeature but an outright bug in an earlier fix to \n13208572fbe8838fd8835548d7502202d1f7b21d (builtin-commit: fix --signoff)\n\nCan you try this and see if it works for you?\n\n-- >8 --\nRe-fix \"builtin-commit: fix --signoff\"\n\nAn earlier fix to the said commit was incomplete; it mixed up the\nmeaning of the flag parameter passed to the internal fmt_ident()\nfunction, so this corrects it.\n\ngit_author_info() and git_committer_info() can be told to issue a\nwarning when no usable user information is found, and optionally can be\ntold to error out.  Operations that actually use the information to\nrecord a new commit or a tag will still error out, but the caller to\nleave reflog record will just silently use bogus user information.\n\nNot warning on misconfigured user information while writing a reflog\nentry is somewhat debatable, but it is probably nicer to the users to\nsilently let it pass, because the only information you are losing is who\nchecked out the branch.\n\n * git_author_info() and git_committer_info() used to take 1 (positive\n   int) to error out with a warning on misconfiguration; this is now\n   signalled with a symbolic constant IDENT_ERROR_ON_NO_NAME.\n\n * These functions used to take -1 (negative int) to warn but continue;\n   this is now signalled with a symbolic constant IDENT_WARN_ON_NO_NAME.\n\n * fmt_ident() function implements the above error reporting behaviour\n   common to git_author_info() and git_committer_info().  A symbolic\n   constant IDENT_NO_DATE can be or'ed in to the flag parameter to make\n   it return only the \"Name <email@address.xz>\".\n\n * fmt_name() is a thin wrapper around fmt_ident() that always passes\n   IDENT_ERROR_ON_NO_NAME and IDENT_NO_DATE.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n builtin-commit-tree.c |    4 ++--\n builtin-commit.c      |    4 ++--\n builtin-log.c         |    4 ++--\n builtin-tag.c         |    4 ++--\n cache.h               |    3 +++\n ident.c               |   30 ++++++++++++------------------\n refs.c                |    2 +-\n var.c                 |    4 ++--\n 8 files changed, 26 insertions(+), 29 deletions(-)\n\ndiff --git a/builtin-commit-tree.c b/builtin-commit-tree.c\nindex 88b0ab3..6610d18 100644\n--- a/builtin-commit-tree.c\n+++ b/builtin-commit-tree.c\n@@ -98,8 +98,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)\n \t\tstrbuf_addf(&buffer, \"parent %s\\n\", sha1_to_hex(parent_sha1[i]));\n \n \t/* Person/date information */\n-\tstrbuf_addf(&buffer, \"author %s\\n\", git_author_info(1));\n-\tstrbuf_addf(&buffer, \"committer %s\\n\", git_committer_info(1));\n+\tstrbuf_addf(&buffer, \"author %s\\n\", git_author_info(IDENT_ERROR_ON_NO_NAME));\n+\tstrbuf_addf(&buffer, \"committer %s\\n\", git_committer_info(IDENT_ERROR_ON_NO_NAME));\n \tif (!encoding_is_utf8)\n \t\tstrbuf_addf(&buffer, \"encoding %s\\n\", git_commit_encoding);\n \tstrbuf_addch(&buffer, '\\n');\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 19297ac..a7e8d4a 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -497,7 +497,7 @@ static void determine_author_info(struct strbuf *sb)\n \t\temail = xstrndup(lb + 2, rb - (lb + 2));\n \t}\n \n-\tstrbuf_addf(sb, \"author %s\\n\", fmt_ident(name, email, date, 1));\n+\tstrbuf_addf(sb, \"author %s\\n\", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));\n }\n \n static int parse_and_validate_options(int argc, const char *argv[],\n@@ -776,7 +776,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t}\n \n \tdetermine_author_info(&sb);\n-\tstrbuf_addf(&sb, \"committer %s\\n\", git_committer_info(1));\n+\tstrbuf_addf(&sb, \"committer %s\\n\", git_committer_info(IDENT_ERROR_ON_NO_NAME));\n \tif (!is_encoding_utf8(git_commit_encoding))\n \t\tstrbuf_addf(&sb, \"encoding %s\\n\", git_commit_encoding);\n \tstrbuf_addch(&sb, '\\n');\ndiff --git a/builtin-log.c b/builtin-log.c\nindex e1f1cf6..b6a1122 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -557,7 +557,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha\n \n static void gen_message_id(char *dest, unsigned int length, char *base)\n {\n-\tconst char *committer = git_committer_info(-1);\n+\tconst char *committer = git_committer_info(IDENT_WARN_ON_NO_NAME);\n \tconst char *email_start = strrchr(committer, '<');\n \tconst char *email_end = strrchr(committer, '>');\n \tif(!email_start || !email_end || email_start > email_end - 1)\n@@ -665,7 +665,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\t !strcmp(argv[i], \"-s\")) {\n \t\t\tconst char *committer;\n \t\t\tconst char *endpos;\n-\t\t\tcommitter = git_committer_info(1);\n+\t\t\tcommitter = git_committer_info(IDENT_ERROR_ON_NO_NAME);\n \t\t\tendpos = strchr(committer, '>');\n \t\t\tif (!endpos)\n \t\t\t\tdie(\"bogos committer info %s\\n\", committer);\ndiff --git a/builtin-tag.c b/builtin-tag.c\nindex 729389b..36a5e9d 100644\n--- a/builtin-tag.c\n+++ b/builtin-tag.c\n@@ -186,7 +186,7 @@ static int do_sign(struct strbuf *buffer)\n \tint len;\n \n \tif (!*signingkey) {\n-\t\tif (strlcpy(signingkey, git_committer_info(1),\n+\t\tif (strlcpy(signingkey, git_committer_info(IDENT_ERROR_ON_NO_NAME),\n \t\t\t\tsizeof(signingkey)) > sizeof(signingkey) - 1)\n \t\t\treturn error(\"committer info too long.\");\n \t\tbracket = strchr(signingkey, '>');\n@@ -296,7 +296,7 @@ static void create_tag(const unsigned char *object, const char *tag,\n \t\t\t  sha1_to_hex(object),\n \t\t\t  typename(type),\n \t\t\t  tag,\n-\t\t\t  git_committer_info(1));\n+\t\t\t  git_committer_info(IDENT_ERROR_ON_NO_NAME));\n \n \tif (header_len > sizeof(header_buf) - 1)\n \t\tdie(\"tag header too big.\");\ndiff --git a/cache.h b/cache.h\nindex 406befb..c6142e9 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -453,6 +453,9 @@ void datestamp(char *buf, int bufsize);\n unsigned long approxidate(const char *);\n enum date_mode parse_date_format(const char *format);\n \n+#define IDENT_WARN_ON_NO_NAME  1\n+#define IDENT_ERROR_ON_NO_NAME 2\n+#define IDENT_NO_DATE\t       4\n extern const char *git_author_info(int);\n extern const char *git_committer_info(int);\n extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);\ndiff --git a/ident.c b/ident.c\nindex 7631698..892d77a 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -182,14 +182,15 @@ static const char *env_hint =\n \"Omit --global to set the identity only in this repository.\\n\"\n \"\\n\";\n \n-static const char *fmt_ident_1(const char *name, const char *email,\n-\t\t\t       const char *date_str, int flag)\n+const char *fmt_ident(const char *name, const char *email,\n+\t\t      const char *date_str, int flag)\n {\n \tstatic char buffer[1000];\n \tchar date[50];\n \tint i;\n-\tint error_on_no_name = !!(flag & 01);\n-\tint name_addr_only = !!(flag & 02);\n+\tint error_on_no_name = (flag & IDENT_ERROR_ON_NO_NAME);\n+\tint warn_on_no_name = (flag & IDENT_WARN_ON_NO_NAME);\n+\tint name_addr_only = (flag & IDENT_NO_DATE);\n \n \tsetup_ident();\n \tif (!name)\n@@ -200,12 +201,12 @@ static const char *fmt_ident_1(const char *name, const char *email,\n \tif (!*name) {\n \t\tstruct passwd *pw;\n \n-\t\tif (0 <= error_on_no_name &&\n+\t\tif ((warn_on_no_name || error_on_no_name) &&\n \t\t    name == git_default_name && env_hint) {\n \t\t\tfprintf(stderr, env_hint, au_env, co_env);\n \t\t\tenv_hint = NULL; /* warn only once, for \"git-var -l\" */\n \t\t}\n-\t\tif (0 < error_on_no_name)\n+\t\tif (error_on_no_name)\n \t\t\tdie(\"empty ident %s <%s> not allowed\", name, email);\n \t\tpw = getpwuid(getuid());\n \t\tif (!pw)\n@@ -234,30 +235,23 @@ static const char *fmt_ident_1(const char *name, const char *email,\n \treturn buffer;\n }\n \n-const char *fmt_ident(const char *name, const char *email,\n-\t\t      const char *date_str, int error_on_no_name)\n-{\n-\tint flag = (error_on_no_name ? 01 : 0);\n-\treturn fmt_ident_1(name, email, date_str, flag);\n-}\n-\n const char *fmt_name(const char *name, const char *email)\n {\n-\treturn fmt_ident_1(name, email, NULL, 03);\n+\treturn fmt_ident(name, email, NULL, IDENT_ERROR_ON_NO_NAME | IDENT_NO_DATE);\n }\n \n-const char *git_author_info(int error_on_no_name)\n+const char *git_author_info(int flag)\n {\n \treturn fmt_ident(getenv(\"GIT_AUTHOR_NAME\"),\n \t\t\t getenv(\"GIT_AUTHOR_EMAIL\"),\n \t\t\t getenv(\"GIT_AUTHOR_DATE\"),\n-\t\t\t error_on_no_name);\n+\t\t\t flag);\n }\n \n-const char *git_committer_info(int error_on_no_name)\n+const char *git_committer_info(int flag)\n {\n \treturn fmt_ident(getenv(\"GIT_COMMITTER_NAME\"),\n \t\t\t getenv(\"GIT_COMMITTER_EMAIL\"),\n \t\t\t getenv(\"GIT_COMMITTER_DATE\"),\n-\t\t\t error_on_no_name);\n+\t\t\t flag);\n }\ndiff --git a/refs.c b/refs.c\nindex 3e6e98c..759924d 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1094,7 +1094,7 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,\n \tadjust_shared_perm(log_file);\n \n \tmsglen = msg ? strlen(msg) : 0;\n-\tcommitter = git_committer_info(-1);\n+\tcommitter = git_committer_info(0);\n \tmaxlen = strlen(committer) + msglen + 100;\n \tlogrec = xmalloc(maxlen);\n \tlen = sprintf(logrec, \"%s %s %s\\n\",\ndiff --git a/var.c b/var.c\nindex 4127031..0de0efa 100644\n--- a/var.c\n+++ b/var.c\n@@ -21,7 +21,7 @@ static void list_vars(void)\n {\n \tstruct git_var *ptr;\n \tfor(ptr = git_vars; ptr->read; ptr++) {\n-\t\tprintf(\"%s=%s\\n\", ptr->name, ptr->read(0));\n+\t\tprintf(\"%s=%s\\n\", ptr->name, ptr->read(IDENT_WARN_ON_NO_NAME));\n \t}\n }\n \n@@ -32,7 +32,7 @@ static const char *read_var(const char *var)\n \tval = NULL;\n \tfor(ptr = git_vars; ptr->read; ptr++) {\n \t\tif (strcmp(var, ptr->name) == 0) {\n-\t\t\tval = ptr->read(1);\n+\t\t\tval = ptr->read(IDENT_ERROR_ON_NO_NAME);\n \t\t\tbreak;\n \t\t}\n \t}\n"},{"id":"62700","messageId":"2A5EA5CA-5A8E-4A9F-9D5C-AAEEFAB1910A@lrde.epita.fr","threadId":"11201","inReplyTo":"7vzlwktzzb.fsf@gitster.siamese.dyndns.org","subject":"Re: [Misfeature] cloning without configuration fails and returns 0","fromName":"Benoit Sigoure","fromEmail":"tsuna@lrde.epita.fr","sentAt":"2007-12-11T11:42:11Z","receivedAt":"2007-12-11T11:42:11Z","isPatch":false,"sender":{"key":"tsunanet@gmail.com","avatar":"https://avatars.githubusercontent.com/u/128281?v=4"},"body":"On Dec 9, 2007, at 2:32 AM, Junio C Hamano wrote:\n\n> Benoit Sigoure <tsuna@lrde.epita.fr> writes:\n>\n>> on a new machine I have access to, I fetched tonight's git master  \n>> (git\n>> version 1.5.3.7.g9758e) and installed it on my account in order  to\n>> clone one of my projects.  I did not setup anything in my git config\n>> and stumbled on the following misfeature:\n>\n> This is not a misfeature but an outright bug in an earlier fix to\n> 13208572fbe8838fd8835548d7502202d1f7b21d (builtin-commit: fix -- \n> signoff)\n>\n> Can you try this and see if it works for you?\n\nYes, thank you.\n\n>\n> -- >8 --\n> Re-fix \"builtin-commit: fix --signoff\"\n>\n> An earlier fix to the said commit was incomplete; it mixed up the\n> meaning of the flag parameter passed to the internal fmt_ident()\n> function, so this corrects it.\n>\n[...]\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>\n>  builtin-commit-tree.c |    4 ++--\n>  builtin-commit.c      |    4 ++--\n>  builtin-log.c         |    4 ++--\n>  builtin-tag.c         |    4 ++--\n>  cache.h               |    3 +++\n>  ident.c               |   30 ++++++++++++------------------\n>  refs.c                |    2 +-\n>  var.c                 |    4 ++--\n>  8 files changed, 26 insertions(+), 29 deletions(-)\n\n-- \nBenoit Sigoure aka Tsuna\nEPITA Research and Development Laboratory\n"}]}