{"thread":{"id":"10212","subject":"[PATCH] git-config: print error message if the config file cannot be read","startedAt":"2007-10-09T12:51:02Z","lastAt":"2007-10-12T11:59:44Z","messageCount":5,"participants":["Gerrit Pape","Johannes Schindelin","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"55267","messageId":"20071009125102.1305.qmail@054bd0fc8effa5.315fe32.mid.smarden.org","threadId":"10212","inReplyTo":null,"subject":"[PATCH] git-config: print error message if the config file cannot be read","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2007-10-09T12:51:02Z","receivedAt":"2007-10-09T12:51:02Z","isPatch":true,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"Instead of simply exiting with 255, print an error message including\nthe reason why the config file cannot be opened or read.\n\nThe problem was noticed by Joey Hess, reported through\n http://bugs.debian.org/445208\n\nSigned-off-by: Gerrit Pape <pape@smarden.org>\n---\n builtin-config.c |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-config.c b/builtin-config.c\nindex 1bb0ebb..750a403 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -235,8 +235,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\targv++;\n \t}\n \n-\tif (show_all)\n-\t\treturn git_config(show_all_config);\n+\tif (show_all) {\n+\t\tif (git_config(show_all_config) == -1)\n+\t\t\tdie(\"unable to read config file %s: %s\",\n+\t\t\t    getenv(CONFIG_ENVIRONMENT), strerror(errno));\n+\t\treturn 0;\n+\t}\n \tswitch (argc) {\n \tcase 2:\n \t\treturn get_value(argv[1], NULL);\n-- \n1.5.3.4\n"},{"id":"55278","messageId":"Pine.LNX.4.64.0710091416090.4174@racer.site","threadId":"10212","inReplyTo":"20071009125102.1305.qmail@054bd0fc8effa5.315fe32.mid.smarden.org","subject":"Re: [PATCH] git-config: print error message if the config file cannot be read","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-09T13:16:41Z","receivedAt":"2007-10-09T13:16:41Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 9 Oct 2007, Gerrit Pape wrote:\n\n> +\t\tif (git_config(show_all_config) == -1)\n\nI'd rather check for < 0, just for future proofing.\n\nCiao,\nDscho\n"},{"id":"55281","messageId":"470B8286.5060006@viscovery.net","threadId":"10212","inReplyTo":"20071009125102.1305.qmail@054bd0fc8effa5.315fe32.mid.smarden.org","subject":"Re: [PATCH] git-config: print error message if the config file cannot be read","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2007-10-09T13:30:46Z","receivedAt":"2007-10-09T13:30:46Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Gerrit Pape schrieb:\n> @@ -235,8 +235,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n>  \t\targv++;\n>  \t}\n>  \n> -\tif (show_all)\n> -\t\treturn git_config(show_all_config);\n> +\tif (show_all) {\n> +\t\tif (git_config(show_all_config) == -1)\n> +\t\t\tdie(\"unable to read config file %s: %s\",\n> +\t\t\t    getenv(CONFIG_ENVIRONMENT), strerror(errno));\n\nI don't think that this works well: If there are no config files at all, \nthen we don't want to see an error - just as if the config file were empty.\n\nAlso, I don't think that errno is reliable at this point.\n\nYou probably want to see an error message *only* if you have supplied a file \nname with --file.\n\n-- Hannes\n"},{"id":"55549","messageId":"20071012114057.30803.qmail@12f4c67b8560e2.315fe32.mid.smarden.org","threadId":"10212","inReplyTo":"470B8286.5060006@viscovery.net","subject":"[PATCH amend] git-config: print error message if the config file cannot be read","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2007-10-12T11:40:57Z","receivedAt":"2007-10-12T11:40:57Z","isPatch":true,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"Instead of simply exiting with 255, print an error message including\nthe reason why a config file specified through --file cannot be opened\nor read.\n\nThe problem was noticed by Joey Hess, reported through\n http://bugs.debian.org/445208\n---\n\nOn Tue, Oct 09, 2007 at 02:16:41PM +0100, Johannes Schindelin wrote:\n> On Tue, 9 Oct 2007, Gerrit Pape wrote:\n> > +           if (git_config(show_all_config) == -1)\n> I'd rather check for < 0, just for future proofing.\n\nOkay.\n\nOn Tue, Oct 09, 2007 at 03:30:46PM +0200, Johannes Sixt wrote:\n> Gerrit Pape schrieb:\n> >+    if (show_all) {\n> >+            if (git_config(show_all_config) == -1)\n> >+                    die(\"unable to read config file %s: %s\",\n> >+                        getenv(CONFIG_ENVIRONMENT), strerror(errno));\n> I don't think that this works well: If there are no config files at\n> all, then we don't want to see an error - just as if the config file\n> were empty.\n>\n> Also, I don't think that errno is reliable at this point.\n>\n> You probably want to see an error message *only* if you have supplied\n> a file name with --file.\n\nI changed the patch to die() only if --file was sepcified, and errno is\nnot 0.\n\nThanks, Gerrit.\n\n\n builtin-config.c |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-config.c b/builtin-config.c\nindex 4444d52..e5bf791 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -172,8 +172,12 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t\ttype = T_INT;\n \t\telse if (!strcmp(argv[1], \"--bool\"))\n \t\t\ttype = T_BOOL;\n-\t\telse if (!strcmp(argv[1], \"--list\") || !strcmp(argv[1], \"-l\"))\n-\t\t\treturn git_config(show_all_config);\n+\t\telse if (!strcmp(argv[1], \"--list\") || !strcmp(argv[1], \"-l\")) {\n+\t\t\tif (git_config(show_all_config) < 0 && file && errno)\n+\t\t\t\tdie(\"unable to read config file %s: %s\", file,\n+\t\t\t\t    strerror(errno));\n+\t\t\treturn 0;\n+\t\t}\n \t\telse if (!strcmp(argv[1], \"--global\")) {\n \t\t\tchar *home = getenv(\"HOME\");\n \t\t\tif (home) {\n-- \n1.5.3.4\n"},{"id":"55550","messageId":"470F61B0.40907@viscovery.net","threadId":"10212","inReplyTo":"20071012114057.30803.qmail@12f4c67b8560e2.315fe32.mid.smarden.org","subject":"Re: [PATCH amend] git-config: print error message if the config file cannot be read","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2007-10-12T11:59:44Z","receivedAt":"2007-10-12T11:59:44Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Gerrit Pape schrieb:\n>> You probably want to see an error message *only* if you have supplied\n>> a file name with --file.\n> \n> I changed the patch to die() only if --file was sepcified, and errno is\n> not 0.\n\nThanks. I can live with that. ;)\n\n-- Hannes\n"}]}