{"thread":{"id":"37212","subject":"[RFC PATCH 3/3] commit: advertize config --global --edit on guessed identity","startedAt":"2014-07-25T13:44:49Z","lastAt":"2014-07-25T18:16:20Z","messageCount":13,"participants":["Matthieu Moy","Tanay Abhra","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"246699","messageId":"1406295891-7316-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"37212","inReplyTo":null,"subject":"[RFC PATCH 1/3] config --global --edit: create a template file if needed","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2014-07-25T13:44:49Z","receivedAt":"2014-07-25T13:44:49Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"When the user has no ~/.gitconfig file, git config --global --edit used\nto launch an editor on an nonexistant file name.\n\nInstead, create a file with a default content before launching the\neditor. The template contains only commented-out entries, to save a few\nkeystrokes for the user. If the values are guessed properly, the user\nwill only have to uncomment the entries.\n\nAdvanced users teaching newbies can create a minimalistic configuration\nfaster for newbies. Beginners reading a tutorial advising to run \"git\nconfig --global --edit\" as a first step will be slightly more guided for\ntheir first contact with Git.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n builtin/config.c | 30 +++++++++++++++++++++++++++---\n cache.h          |  1 +\n ident.c          |  2 +-\n 3 files changed, 29 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex fcd8474..3821697 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -445,6 +445,20 @@ static int get_urlmatch(const char *var, const char *url)\n \treturn 0;\n }\n \n+static char *default_user_config()\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tstrbuf_addf(&buf,\n+\t\t    _(\"# This is Git's user-wide configuration file.\\n\"\n+\t\t      \"[core]\\n\"\n+\t\t      \"# Please, adapt and uncomment the following lines:\\n\"\n+\t\t      \"#\tuser = %s\\n\"\n+\t\t      \"#\temail = %s\\n\"),\n+\t\t    ident_default_name(),\n+\t\t    ident_default_email());\n+\treturn strbuf_detach(&buf, NULL);\n+}\n+\n int cmd_config(int argc, const char **argv, const char *prefix)\n {\n \tint nongit = !startup_info->have_repository;\n@@ -551,6 +565,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t}\n \t}\n \telse if (actions == ACTION_EDIT) {\n+\t\tconst char *config_file = given_config_source.file ?\n+\t\t\tgiven_config_source.file : git_path(\"config\");\n \t\tcheck_argc(argc, 0, 0);\n \t\tif (!given_config_source.file && nongit)\n \t\t\tdie(\"not in a git directory\");\n@@ -559,9 +575,17 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\tif (given_config_source.blob)\n \t\t\tdie(\"editing blobs is not supported\");\n \t\tgit_config(git_default_config, NULL);\n-\t\tlaunch_editor(given_config_source.file ?\n-\t\t\t      given_config_source.file : git_path(\"config\"),\n-\t\t\t      NULL, NULL);\n+\t\tif (use_global_config) {\n+\t\t\tint fd = open(config_file, O_CREAT | O_EXCL | O_WRONLY, 0666);\n+\t\t\tif (fd) {\n+\t\t\t\tchar *content = default_user_config();\n+\t\t\t\twrite_str_in_full(fd, content);\n+\t\t\t\tfree(content);\n+\t\t\t}\n+\t\t\telse if (errno != EEXIST)\n+\t\t\t\tdie_errno(_(\"Cannot create configuration file %s\"), config_file);\n+\t\t}\n+\t\tlaunch_editor(config_file, NULL, NULL);\n \t}\n \telse if (actions == ACTION_SET) {\n \t\tint ret;\ndiff --git a/cache.h b/cache.h\nindex 2f63fd1..8c79c0c 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1061,6 +1061,7 @@ 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);\n extern const char *fmt_name(const char *name, const char *email);\n+extern const char *ident_default_name(void);\n extern const char *ident_default_email(void);\n extern const char *git_editor(void);\n extern const char *git_pager(int stdout_is_tty);\ndiff --git a/ident.c b/ident.c\nindex 1d9b6e7..77bc882 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -102,7 +102,7 @@ static void copy_email(const struct passwd *pw, struct strbuf *email)\n \tadd_domainname(email);\n }\n \n-static const char *ident_default_name(void)\n+const char *ident_default_name(void)\n {\n \tif (!git_default_name.len) {\n \t\tcopy_gecos(xgetpwuid_self(), &git_default_name);\n-- \n2.0.2.737.gfb43bde\n"},{"id":"246700","messageId":"1406295891-7316-2-git-send-email-Matthieu.Moy@imag.fr","threadId":"37212","inReplyTo":"1406295891-7316-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[RFC PATCH 2/3] home_config_path: allow NULL xdg parameter","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2014-07-25T13:44:50Z","receivedAt":"2014-07-25T13:44:50Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"This allows a caller to requst the global config file without requesting\nthe XDG one.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\nThis is actually not needed, but I wrote this for a previous version,\nand it seems sensible anyway.\n\n path.c | 10 ++++++----\n 1 file changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/path.c b/path.c\nindex 3afcdb4..f68df0c 100644\n--- a/path.c\n+++ b/path.c\n@@ -148,10 +148,12 @@ void home_config_paths(char **global, char **xdg, char *file)\n \t\t\t*global = mkpathdup(\"%s/.gitconfig\", home);\n \t}\n \n-\tif (!xdg_home)\n-\t\t*xdg = NULL;\n-\telse\n-\t\t*xdg = mkpathdup(\"%s/git/%s\", xdg_home, file);\n+\tif (xdg) {\n+\t\tif (!xdg_home)\n+\t\t\t*xdg = NULL;\n+\t\telse\n+\t\t\t*xdg = mkpathdup(\"%s/git/%s\", xdg_home, file);\n+\t}\n \n \tfree(to_free);\n }\n-- \n2.0.2.737.gfb43bde\n"},{"id":"246698","messageId":"1406295891-7316-3-git-send-email-Matthieu.Moy@imag.fr","threadId":"37212","inReplyTo":"1406295891-7316-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[RFC PATCH 3/3] commit: advertize config --global --edit on guessed identity","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2014-07-25T13:44:51Z","receivedAt":"2014-07-25T13:44:51Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"When the user has no user-wide configuration file, it's faster to use the\nnewly introduced config file template than to run two commands to set\nuser.name and user.email. Advise this to the user.\n\nThe old advice is kept if the user already has a configuration file since\nthe template feature would not trigger in this case.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n builtin/commit.c | 34 ++++++++++++++++++++++++++++++++--\n 1 file changed, 32 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex f2d7979..52ef5a8 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -42,7 +42,20 @@ static const char * const builtin_status_usage[] = {\n \tNULL\n };\n \n-static const char implicit_ident_advice[] =\n+static const char implicit_ident_advice_noconfig[] =\n+N_(\"Your name and email address were configured automatically based\\n\"\n+\"on your username and hostname. Please check that they are accurate.\\n\"\n+\"You can suppress this message by setting them explicitly. Run the\\n\"\n+\"following command and follow the instructions in your editor to edit\\n\"\n+\"your configuration file:\\n\"\n+\"\\n\"\n+\"    git config --global --edit\\n\"\n+\"\\n\"\n+\"After doing this, you may fix the identity used for this commit with:\\n\"\n+\"\\n\"\n+\"    git commit --amend --reset-author\\n\");\n+\n+static const char implicit_ident_advice_config[] =\n N_(\"Your name and email address were configured automatically based\\n\"\n \"on your username and hostname. Please check that they are accurate.\\n\"\n \"You can suppress this message by setting them explicitly:\\n\"\n@@ -1403,6 +1416,23 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \treturn 0;\n }\n \n+static const char *implicit_ident_advice() {\n+\tchar *user_config = NULL;\n+\tchar *xdg_config = NULL;\n+\tint config_exists;\n+\n+\thome_config_paths(&user_config, &xdg_config, \"config\");\n+\tconfig_exists = file_exists(user_config) || file_exists(xdg_config);\n+\tfree(user_config);\n+\tfree(xdg_config);\n+\n+\tif (config_exists)\n+\t\treturn _(implicit_ident_advice_config);\n+\telse\n+\t\treturn _(implicit_ident_advice_noconfig);\n+\n+}\n+\n static void print_summary(const char *prefix, const unsigned char *sha1,\n \t\t\t  int initial_commit)\n {\n@@ -1441,7 +1471,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1,\n \t\tstrbuf_addbuf_percentquote(&format, &committer_ident);\n \t\tif (advice_implicit_identity) {\n \t\t\tstrbuf_addch(&format, '\\n');\n-\t\t\tstrbuf_addstr(&format, _(implicit_ident_advice));\n+\t\t\tstrbuf_addstr(&format, implicit_ident_advice());\n \t\t}\n \t}\n \tstrbuf_release(&author_ident);\n-- \n2.0.2.737.gfb43bde\n"},{"id":"246701","messageId":"53D2625C.9070702@gmail.com","threadId":"37212","inReplyTo":"1406295891-7316-2-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [RFC PATCH 2/3] home_config_path: allow NULL xdg parameter","fromName":"Tanay Abhra","fromEmail":"tanayabh@gmail.com","sentAt":"2014-07-25T13:57:48Z","receivedAt":"2014-07-25T13:57:48Z","isPatch":true,"sender":{"key":"tanayabh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2097229?v=4"},"body":"On 7/25/2014 7:14 PM, Matthieu Moy wrote:\n> This allows a caller to requst the global config file without requesting\nnit s/requst/request/\n"},{"id":"246706","messageId":"CAPig+cSyLtUmkxAcO+iatKSS2t2T5byXRrJYq=MSuBoZ3m=hcw@mail.gmail.com","threadId":"37212","inReplyTo":"1406295891-7316-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [RFC PATCH 1/3] config --global --edit: create a template file if needed","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-07-25T15:37:09Z","receivedAt":"2014-07-25T15:37:09Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Jul 25, 2014 at 9:44 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:\n> When the user has no ~/.gitconfig file, git config --global --edit used\n> to launch an editor on an nonexistant file name.\n>\n> Instead, create a file with a default content before launching the\n> editor. The template contains only commented-out entries, to save a few\n> keystrokes for the user. If the values are guessed properly, the user\n> will only have to uncomment the entries.\n>\n> Advanced users teaching newbies can create a minimalistic configuration\n> faster for newbies. Beginners reading a tutorial advising to run \"git\n> config --global --edit\" as a first step will be slightly more guided for\n> their first contact with Git.\n>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n>  builtin/config.c | 30 +++++++++++++++++++++++++++---\n>  cache.h          |  1 +\n>  ident.c          |  2 +-\n>  3 files changed, 29 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin/config.c b/builtin/config.c\n> index fcd8474..3821697 100644\n> --- a/builtin/config.c\n> +++ b/builtin/config.c\n> @@ -445,6 +445,20 @@ static int get_urlmatch(const char *var, const char *url)\n>         return 0;\n>  }\n>\n> +static char *default_user_config()\n> +{\n> +       struct strbuf buf = STRBUF_INIT;\n> +       strbuf_addf(&buf,\n> +                   _(\"# This is Git's user-wide configuration file.\\n\"\n> +                     \"[core]\\n\"\n> +                     \"# Please, adapt and uncomment the following lines:\\n\"\n> +                     \"#        user = %s\\n\"\n> +                     \"#        email = %s\\n\"),\n\n\"[core]\", \"user =\", \"email =\" should not be translated. Would it make\nsense to keep these outside of _()?\n\n> +                   ident_default_name(),\n> +                   ident_default_email());\n> +       return strbuf_detach(&buf, NULL);\n> +}\n> +\n>  int cmd_config(int argc, const char **argv, const char *prefix)\n>  {\n>         int nongit = !startup_info->have_repository;\n> @@ -551,6 +565,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n>                 }\n>         }\n>         else if (actions == ACTION_EDIT) {\n> +               const char *config_file = given_config_source.file ?\n> +                       given_config_source.file : git_path(\"config\");\n>                 check_argc(argc, 0, 0);\n>                 if (!given_config_source.file && nongit)\n>                         die(\"not in a git directory\");\n> @@ -559,9 +575,17 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n>                 if (given_config_source.blob)\n>                         die(\"editing blobs is not supported\");\n>                 git_config(git_default_config, NULL);\n> -               launch_editor(given_config_source.file ?\n> -                             given_config_source.file : git_path(\"config\"),\n> -                             NULL, NULL);\n> +               if (use_global_config) {\n> +                       int fd = open(config_file, O_CREAT | O_EXCL | O_WRONLY, 0666);\n> +                       if (fd) {\n> +                               char *content = default_user_config();\n> +                               write_str_in_full(fd, content);\n\nclose(fd);\n\n> +                               free(content);\n> +                       }\n> +                       else if (errno != EEXIST)\n> +                               die_errno(_(\"Cannot create configuration file %s\"), config_file);\n\nOther error messages in this file (including those just above this\nblock) begin with a lowercase letter.\n\n> +               }\n> +               launch_editor(config_file, NULL, NULL);\n>         }\n>         else if (actions == ACTION_SET) {\n>                 int ret;\n> diff --git a/cache.h b/cache.h\n> index 2f63fd1..8c79c0c 100644\n> --- a/cache.h\n> +++ b/cache.h\n> @@ -1061,6 +1061,7 @@ 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);\n>  extern const char *fmt_name(const char *name, const char *email);\n> +extern const char *ident_default_name(void);\n>  extern const char *ident_default_email(void);\n>  extern const char *git_editor(void);\n>  extern const char *git_pager(int stdout_is_tty);\n> diff --git a/ident.c b/ident.c\n> index 1d9b6e7..77bc882 100644\n> --- a/ident.c\n> +++ b/ident.c\n> @@ -102,7 +102,7 @@ static void copy_email(const struct passwd *pw, struct strbuf *email)\n>         add_domainname(email);\n>  }\n>\n> -static const char *ident_default_name(void)\n> +const char *ident_default_name(void)\n>  {\n>         if (!git_default_name.len) {\n>                 copy_gecos(xgetpwuid_self(), &git_default_name);\n> --\n> 2.0.2.737.gfb43bde\n"},{"id":"246707","messageId":"CAPig+cQCD7rxVyJk9pLx6u6UEskm+25rhuraXNLUDNk3_SJYwA@mail.gmail.com","threadId":"37212","inReplyTo":"1406295891-7316-3-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [RFC PATCH 3/3] commit: advertize config --global --edit on guessed identity","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-07-25T15:40:27Z","receivedAt":"2014-07-25T15:40:27Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Jul 25, 2014 at 9:44 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:\n> commit: advertize config --global --edit on guessed identity\n\ns/advertize/advertise/\n\n> When the user has no user-wide configuration file, it's faster to use the\n> newly introduced config file template than to run two commands to set\n> user.name and user.email. Advise this to the user.\n>\n> The old advice is kept if the user already has a configuration file since\n> the template feature would not trigger in this case.\n>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n>  builtin/commit.c | 34 ++++++++++++++++++++++++++++++++--\n>  1 file changed, 32 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index f2d7979..52ef5a8 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -42,7 +42,20 @@ static const char * const builtin_status_usage[] = {\n>         NULL\n>  };\n>\n> -static const char implicit_ident_advice[] =\n> +static const char implicit_ident_advice_noconfig[] =\n> +N_(\"Your name and email address were configured automatically based\\n\"\n> +\"on your username and hostname. Please check that they are accurate.\\n\"\n> +\"You can suppress this message by setting them explicitly. Run the\\n\"\n> +\"following command and follow the instructions in your editor to edit\\n\"\n> +\"your configuration file:\\n\"\n> +\"\\n\"\n> +\"    git config --global --edit\\n\"\n> +\"\\n\"\n> +\"After doing this, you may fix the identity used for this commit with:\\n\"\n> +\"\\n\"\n> +\"    git commit --amend --reset-author\\n\");\n> +\n> +static const char implicit_ident_advice_config[] =\n>  N_(\"Your name and email address were configured automatically based\\n\"\n>  \"on your username and hostname. Please check that they are accurate.\\n\"\n>  \"You can suppress this message by setting them explicitly:\\n\"\n> @@ -1403,6 +1416,23 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n>         return 0;\n>  }\n>\n> +static const char *implicit_ident_advice() {\n> +       char *user_config = NULL;\n> +       char *xdg_config = NULL;\n> +       int config_exists;\n> +\n> +       home_config_paths(&user_config, &xdg_config, \"config\");\n> +       config_exists = file_exists(user_config) || file_exists(xdg_config);\n> +       free(user_config);\n> +       free(xdg_config);\n> +\n> +       if (config_exists)\n> +               return _(implicit_ident_advice_config);\n> +       else\n> +               return _(implicit_ident_advice_noconfig);\n> +\n> +}\n> +\n>  static void print_summary(const char *prefix, const unsigned char *sha1,\n>                           int initial_commit)\n>  {\n> @@ -1441,7 +1471,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1,\n>                 strbuf_addbuf_percentquote(&format, &committer_ident);\n>                 if (advice_implicit_identity) {\n>                         strbuf_addch(&format, '\\n');\n> -                       strbuf_addstr(&format, _(implicit_ident_advice));\n> +                       strbuf_addstr(&format, implicit_ident_advice());\n>                 }\n>         }\n>         strbuf_release(&author_ident);\n> --\n> 2.0.2.737.gfb43bde\n"},{"id":"246710","messageId":"vpqtx65ctqm.fsf@anie.imag.fr","threadId":"37212","inReplyTo":"CAPig+cSyLtUmkxAcO+iatKSS2t2T5byXRrJYq=MSuBoZ3m=hcw@mail.gmail.com","subject":"Re: [RFC PATCH 1/3] config --global --edit: create a template file if needed","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-07-25T16:01:53Z","receivedAt":"2014-07-25T16:01:53Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n>> +static char *default_user_config()\n>> +{\n>> +       struct strbuf buf = STRBUF_INIT;\n>> +       strbuf_addf(&buf,\n>> +                   _(\"# This is Git's user-wide configuration file.\\n\"\n>> +                     \"[core]\\n\"\n>> +                     \"# Please, adapt and uncomment the following lines:\\n\"\n>> +                     \"#        user = %s\\n\"\n>> +                     \"#        email = %s\\n\"),\n>\n> \"[core]\", \"user =\", \"email =\" should not be translated. Would it make\n> sense to keep these outside of _()?\n\nI would say no, as the code and the string to translate would be much\nless readable without core, user and email inline.\n\nWere you suggesting stg like\n\n_(\"# This is Git's user-wide configuration file.\\n\"\n  \"[%s]\\n\"\n  \"# Please, adapt and uncomment the following lines:\\n\"\n  \"#        %s = %s\\n\"\n  \"#        %s = %s\\n\"),\n  \"core\", \"name\", ..., \"email\", ...\n\n?\n\n>> +                       if (fd) {\n>> +                               char *content = default_user_config();\n>> +                               write_str_in_full(fd, content);\n>\n> close(fd);\n\nIndeed.\n\n>> +                               free(content);\n>> +                       }\n>> +                       else if (errno != EEXIST)\n>> +                               die_errno(_(\"Cannot create configuration file %s\"), config_file);\n>\n> Other error messages in this file (including those just above this\n> block) begin with a lowercase letter.\n\nApplied.\n\nThanks,\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"246720","messageId":"xmqqioml732e.fsf@gitster.dls.corp.google.com","threadId":"37212","inReplyTo":"1406295891-7316-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [RFC PATCH 1/3] config --global --edit: create a template file if needed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-25T17:36:57Z","receivedAt":"2014-07-25T17:36:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> When the user has no ~/.gitconfig file, git config --global --edit used\n> to launch an editor on an nonexistant file name.\n>\n> Instead, create a file with a default content before launching the\n> editor. The template contains only commented-out entries, to save a few\n> keystrokes for the user. If the values are guessed properly, the user\n> will only have to uncomment the entries.\n>\n> Advanced users teaching newbies can create a minimalistic configuration\n> faster for newbies. Beginners reading a tutorial advising to run \"git\n> config --global --edit\" as a first step will be slightly more guided for\n> their first contact with Git.\n>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n\nProbably a good idea; I do not think of any possible interactions we\nhave to worry about with the configuration file init-db creates with\npossible templating.\n\nDo we use \"user-wide\" as a phrase to refer to these?  It sounds\nsomewhat funny to call anything specific to $frotz \"$frotz-wide\", at\nleast to me.\n\nSurely, /etc/gitconfig is called \"site-wide\".  But .git/config is\nper-project (or project-specific), and I would always have thought\nthat ~/.gitconfig was \"per-user\".\n\n>  builtin/config.c | 30 +++++++++++++++++++++++++++---\n>  cache.h          |  1 +\n>  ident.c          |  2 +-\n>  3 files changed, 29 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin/config.c b/builtin/config.c\n> index fcd8474..3821697 100644\n> --- a/builtin/config.c\n> +++ b/builtin/config.c\n> @@ -445,6 +445,20 @@ static int get_urlmatch(const char *var, const char *url)\n>  \treturn 0;\n>  }\n>  \n> +static char *default_user_config()\n\nstatic char *default_user_config(void)\n\n> +{\n> +\tstruct strbuf buf = STRBUF_INIT;\n> +\tstrbuf_addf(&buf,\n> +\t\t    _(\"# This is Git's user-wide configuration file.\\n\"\n> +\t\t      \"[core]\\n\"\n> +\t\t      \"# Please, adapt and uncomment the following lines:\\n\"\n\ntangent: is it a French tradition to always have comma after please?\n"},{"id":"246722","messageId":"CAPig+cRpcA15_FQj1Cs6M8MFUhvh0UGd2RtAf9aXLQus-mLp6g@mail.gmail.com","threadId":"37212","inReplyTo":"vpqtx65ctqm.fsf@anie.imag.fr","subject":"Re: [RFC PATCH 1/3] config --global --edit: create a template file if needed","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-07-25T17:51:54Z","receivedAt":"2014-07-25T17:51:54Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Jul 25, 2014 at 12:01 PM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n>\n>>> +static char *default_user_config()\n>>> +{\n>>> +       struct strbuf buf = STRBUF_INIT;\n>>> +       strbuf_addf(&buf,\n>>> +                   _(\"# This is Git's user-wide configuration file.\\n\"\n>>> +                     \"[core]\\n\"\n>>> +                     \"# Please, adapt and uncomment the following lines:\\n\"\n>>> +                     \"#        user = %s\\n\"\n>>> +                     \"#        email = %s\\n\"),\n>>\n>> \"[core]\", \"user =\", \"email =\" should not be translated. Would it make\n>> sense to keep these outside of _()?\n>\n> I would say no, as the code and the string to translate would be much\n> less readable without core, user and email inline.\n>\n> Were you suggesting stg like\n>\n> _(\"# This is Git's user-wide configuration file.\\n\"\n>   \"[%s]\\n\"\n>   \"# Please, adapt and uncomment the following lines:\\n\"\n>   \"#        %s = %s\\n\"\n>   \"#        %s = %s\\n\"),\n>   \"core\", \"name\", ..., \"email\", ...\n>\n> ?\n\nThat or some equivalent variation. I'm not a translator, but the above\nseems to convey sufficient context for a translator to understand what\nneeds to be said, while preventing accidental translations of those\nstrings which should not be translated.\n\n>>> +                       if (fd) {\n>>> +                               char *content = default_user_config();\n>>> +                               write_str_in_full(fd, content);\n>>\n>> close(fd);\n>\n> Indeed.\n>\n>>> +                               free(content);\n>>> +                       }\n>>> +                       else if (errno != EEXIST)\n>>> +                               die_errno(_(\"Cannot create configuration file %s\"), config_file);\n>>\n>> Other error messages in this file (including those just above this\n>> block) begin with a lowercase letter.\n>\n> Applied.\n>\n> Thanks,\n>\n> --\n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n"},{"id":"246723","messageId":"vpq61il9vh8.fsf@anie.imag.fr","threadId":"37212","inReplyTo":"xmqqioml732e.fsf@gitster.dls.corp.google.com","subject":"Re: [RFC PATCH 1/3] config --global --edit: create a template file if needed","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-07-25T17:52:35Z","receivedAt":"2014-07-25T17:52:35Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Probably a good idea; I do not think of any possible interactions we\n> have to worry about with the configuration file init-db creates with\n> possible templating.\n\nThe feature should trigger only for --global, so it shouldn't interfer\nwith .git/config and templates.\n\n> Do we use \"user-wide\" as a phrase to refer to these?  It sounds\n> somewhat funny to call anything specific to $frotz \"$frotz-wide\", at\n> least to me.\n>\n> Surely, /etc/gitconfig is called \"site-wide\".  But .git/config is\n> per-project (or project-specific), and I would always have thought\n> that ~/.gitconfig was \"per-user\".\n\nI'm not a native speaker, but to me, \"user-wide\" insists on the fact\nthat it applies to everything for this user, and \"per-user\" insists on\nthe fact that it does not apply to other users.\n\nPerhaps just \"Git's user configuration file\" would be enough.\n\n>>  builtin/config.c | 30 +++++++++++++++++++++++++++---\n>>  cache.h          |  1 +\n>>  ident.c          |  2 +-\n>>  3 files changed, 29 insertions(+), 4 deletions(-)\n>>\n>> diff --git a/builtin/config.c b/builtin/config.c\n>> index fcd8474..3821697 100644\n>> --- a/builtin/config.c\n>> +++ b/builtin/config.c\n>> @@ -445,6 +445,20 @@ static int get_urlmatch(const char *var, const char *url)\n>>  \treturn 0;\n>>  }\n>>  \n>> +static char *default_user_config()\n>\n> static char *default_user_config(void)\n\nRight. Doing too much C++.\n\n>> +{\n>> +\tstruct strbuf buf = STRBUF_INIT;\n>> +\tstrbuf_addf(&buf,\n>> +\t\t    _(\"# This is Git's user-wide configuration file.\\n\"\n>> +\t\t      \"[core]\\n\"\n>> +\t\t      \"# Please, adapt and uncomment the following lines:\\n\"\n>\n> tangent: is it a French tradition to always have comma after please?\n\nPerhaps. In French, the comma would be required after \"S'il vous plait\"\n(litterally, \"if you like\"). I'll remove it.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"246730","messageId":"xmqqegx9720g.fsf@gitster.dls.corp.google.com","threadId":"37212","inReplyTo":"vpqtx65ctqm.fsf@anie.imag.fr","subject":"Re: [RFC PATCH 1/3] config --global --edit: create a template file if needed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-25T17:59:43Z","receivedAt":"2014-07-25T17:59:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n>\n>>> +static char *default_user_config()\n>>> +{\n>>> +       struct strbuf buf = STRBUF_INIT;\n>>> +       strbuf_addf(&buf,\n>>> +                   _(\"# This is Git's user-wide configuration file.\\n\"\n>>> +                     \"[core]\\n\"\n>>> +                     \"# Please, adapt and uncomment the following lines:\\n\"\n>>> +                     \"#        user = %s\\n\"\n>>> +                     \"#        email = %s\\n\"),\n>>\n>> \"[core]\", \"user =\", \"email =\" should not be translated. Would it make\n>> sense to keep these outside of _()?\n>\n> I would say no, as the code and the string to translate would be much\n> less readable without core, user and email inline.\n>\n> Were you suggesting stg like\n>\n> _(\"# This is Git's user-wide configuration file.\\n\"\n>   \"[%s]\\n\"\n>   \"# Please, adapt and uncomment the following lines:\\n\"\n>   \"#        %s = %s\\n\"\n>   \"#        %s = %s\\n\"),\n>   \"core\", \"name\", ..., \"email\", ...\n>\n> ?\n\n;-) That is a clever way to say what my first reaction to Eric's\ncomment was, which was to have this as multiple strbuf_addf().\n\nTechnically speaking, the '#' at the beginning of lines must not be\ntranslated, either, and if that goes without saying, i.e. if the\ntranslators know well enough not to change them, then I can be\npersuaded that we can expect that translators know well enough not\nto touch the three substrings Eric pointed out.\n\nSo, the original message may be fine as-is.\n\n>>> +                       if (fd) {\n>>> +                               char *content = default_user_config();\n>>> +                               write_str_in_full(fd, content);\n>>\n>> close(fd);\n>\n> Indeed.\n>\n>>> +                               free(content);\n>>> +                       }\n>>> +                       else if (errno != EEXIST)\n>>> +                               die_errno(_(\"Cannot create configuration file %s\"), config_file);\n>>\n>> Other error messages in this file (including those just above this\n>> block) begin with a lowercase letter.\n>\n> Applied.\n>\n> Thanks,\n"},{"id":"246734","messageId":"xmqqa97x71p7.fsf@gitster.dls.corp.google.com","threadId":"37212","inReplyTo":"1406295891-7316-2-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [RFC PATCH 2/3] home_config_path: allow NULL xdg parameter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-07-25T18:06:28Z","receivedAt":"2014-07-25T18:06:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> This allows a caller to requst the global config file without requesting\n> the XDG one.\n>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n> This is actually not needed, but I wrote this for a previous version,\n> and it seems sensible anyway.\n\nI was about to say \"Let's not do this until some caller needs it\",\nimplicitly assuming that we do not let global=NULL to signal that\nthe caller is interested only in XDG, but I checked and we do check\nthe NULL-ness of global, so it is consistent to do so for xdg.  The\nchange makes very good sense.\n\nI wouldn't have had to spend the time to dig, if the log message\njustified it that way, instead of having \"actually not needed\"\ncomment there ;-)\n\n\thome_config_paths(): let the caller ignore xdg path\n\n\tThe caller can signal that it is not interested in learning\n\tthe location of $HOME/.gitconfig by passing global=NULL, but\n\tthere is no way to decline the ptah to the configuration\n\tfile based on $XDG_CONFIG_HOME.\n\n        Allow the caller to pass xdg=NULL to signal that it is not\n        interested in the XDG location.\n\nor something, perhaps?\n\n>\n>  path.c | 10 ++++++----\n>  1 file changed, 6 insertions(+), 4 deletions(-)\n>\n> diff --git a/path.c b/path.c\n> index 3afcdb4..f68df0c 100644\n> --- a/path.c\n> +++ b/path.c\n> @@ -148,10 +148,12 @@ void home_config_paths(char **global, char **xdg, char *file)\n>  \t\t\t*global = mkpathdup(\"%s/.gitconfig\", home);\n>  \t}\n>  \n> -\tif (!xdg_home)\n> -\t\t*xdg = NULL;\n> -\telse\n> -\t\t*xdg = mkpathdup(\"%s/git/%s\", xdg_home, file);\n> +\tif (xdg) {\n> +\t\tif (!xdg_home)\n> +\t\t\t*xdg = NULL;\n> +\t\telse\n> +\t\t\t*xdg = mkpathdup(\"%s/git/%s\", xdg_home, file);\n> +\t}\n>  \n>  \tfree(to_free);\n>  }\n"},{"id":"246735","messageId":"vpqa97x483v.fsf@anie.imag.fr","threadId":"37212","inReplyTo":"xmqqa97x71p7.fsf@gitster.dls.corp.google.com","subject":"Re: [RFC PATCH 2/3] home_config_path: allow NULL xdg parameter","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-07-25T18:16:20Z","receivedAt":"2014-07-25T18:16:20Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n>\n>> This allows a caller to requst the global config file without requesting\n>> the XDG one.\n>>\n>> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n>> ---\n>> This is actually not needed, but I wrote this for a previous version,\n>> and it seems sensible anyway.\n>\n> I was about to say \"Let's not do this until some caller needs it\",\n> implicitly assuming that we do not let global=NULL to signal that\n> the caller is interested only in XDG, but I checked and we do check\n> the NULL-ness of global, so it is consistent to do so for xdg.  The\n> change makes very good sense.\n>\n> I wouldn't have had to spend the time to dig, if the log message\n> justified it that way, instead of having \"actually not needed\"\n> comment there ;-)\n>\n> \thome_config_paths(): let the caller ignore xdg path\n>\n> \tThe caller can signal that it is not interested in learning\n> \tthe location of $HOME/.gitconfig by passing global=NULL, but\n> \tthere is no way to decline the ptah to the configuration\n> \tfile based on $XDG_CONFIG_HOME.\n>\n>         Allow the caller to pass xdg=NULL to signal that it is not\n>         interested in the XDG location.\n\nGood point. Applied locally, I'll resend later.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}