{"thread":{"id":"41496","subject":"[PATCH] git config: do not create .git/ if it does not exist yet","startedAt":"2016-02-24T07:47:00Z","lastAt":"2016-02-25T15:54:48Z","messageCount":16,"participants":["Johannes Schindelin","Jeff King","John Keeping","Duy Nguyen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"279130","messageId":"c4027d758b0914dbc2e1ff5df344b0669aac4447.1456299545.git.johannes.schindelin@gmx.de","threadId":"41496","inReplyTo":null,"subject":"[PATCH] git config: do not create .git/ if it does not exist yet","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-24T07:47:00Z","receivedAt":"2016-02-24T07:47:00Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"It is a pilot error to call `git config section.key value` outside of\nany Git worktree.\n\nLet's report that error instead of creating the .git/ directory and\nwriting a fresh config into it.\n\nThis addresses https://github.com/git-for-windows/git/issues/643 and\nhttps://groups.google.com/forum/#!topic/git-for-windows/fVRdnDIKVuw\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tI cannot think of a way how to test this: all of the regression\n\ttests run inside Git's own worktree, and we cannot even assume\n\tthat /tmp/ is outside of a worktree (or that it exists).\n\n builtin/config.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex adc7727..78aab95 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -352,6 +352,9 @@ static int get_colorbool(const char *var, int print)\n \n static void check_write(void)\n {\n+\tif (!given_config_source.file && !startup_info->have_repository)\n+\t\tdie(\"not in a git directory\");\n+\n \tif (given_config_source.use_stdin)\n \t\tdie(\"writing to stdin is not supported\");\n \n-- \n2.7.2.windows.1.2.gbc859c8\n"},{"id":"279135","messageId":"20160224082657.GD12511@sigill.intra.peff.net","threadId":"41496","inReplyTo":"c4027d758b0914dbc2e1ff5df344b0669aac4447.1456299545.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH] git config: do not create .git/ if it does not exist yet","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-02-24T08:26:57Z","receivedAt":"2016-02-24T08:26:57Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 24, 2016 at 08:47:00AM +0100, Johannes Schindelin wrote:\n\n> It is a pilot error to call `git config section.key value` outside of\n> any Git worktree.\n> \n> Let's report that error instead of creating the .git/ directory and\n> writing a fresh config into it.\n\nHmm.  I get (on my Linux machine):\n\n  $ git config foo.bar baz\n  error: could not lock config file .git/config: No such file or directory\n\nwhich makes sense (though still isn't a great error message, and is kind\nof weird if you happen to have a .git directory that isn't a real\nrepository).\n\nIs Git more aggressive about auto-creating the directory for lockfiles\non Windows? I tried the exact recipe you gave in the linked thread, just\nto be sure, but I couldn't replicate it.\n\n> \tI cannot think of a way how to test this: all of the regression\n> \ttests run inside Git's own worktree, and we cannot even assume\n> \tthat /tmp/ is outside of a worktree (or that it exists).\n\nWe could make the test conditional on whether we are in a repo. Anybody\nwho builds from a tarball, or who uses --root would then run the test.\n\nSomething like this:\n\n-- >8 --\ndiff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh\nindex 52678e7..9856831 100755\n--- a/t/t1300-repo-config.sh\n+++ b/t/t1300-repo-config.sh\n@@ -1201,4 +1201,13 @@ test_expect_success POSIXPERM,PERL 'preserves existing permissions' '\n \t  \"die q(badrename) if ((stat(q(.git/config)))[2] & 07777) != 0600\"\n '\n \n+test_expect_success 'set up repo-less tests' '\n+\tmv .git tmp-git &&\n+\t{ git rev-parse --git-dir || test_set_prereq REPOLESS; }\n+'\n+\n+test_expect_success REPOLESS 'cannot set repo config outside of a repo' '\n+\ttest_must_fail git config foo.bar baz\n+'\n+\n test_done\n-- 8< --\n\nThough I admit it is pretty gross. It also pollutes the script state, so\nanybody adding tests after will be in for a surprise. :)\n\nOne solution would be to restore \"tmp-git\" in the set-up, and then have\neach REPOLESS test move it again, and put it back with a\ntest_when_finished. Or perhaps just make a new script for REPOLESS tests\n(config or otherwise).\n\n> diff --git a/builtin/config.c b/builtin/config.c\n> index adc7727..78aab95 100644\n> --- a/builtin/config.c\n> +++ b/builtin/config.c\n> @@ -352,6 +352,9 @@ static int get_colorbool(const char *var, int print)\n>  \n>  static void check_write(void)\n>  {\n> +\tif (!given_config_source.file && !startup_info->have_repository)\n> +\t\tdie(\"not in a git directory\");\n> +\n>  \tif (given_config_source.use_stdin)\n>  \t\tdie(\"writing to stdin is not supported\");\n\nI think you'd want to cover \"git config --local foo.bar baz\" in the same\nway. You can check use_local_config for that.\n\n-Peff\n"},{"id":"279137","messageId":"20160224101403.GN1766@serenity.lan","threadId":"41496","inReplyTo":"20160224082657.GD12511@sigill.intra.peff.net","subject":"Re: [PATCH] git config: do not create .git/ if it does not exist yet","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2016-02-24T10:14:03Z","receivedAt":"2016-02-24T10:14:03Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Wed, Feb 24, 2016 at 03:26:57AM -0500, Jeff King wrote:\n> On Wed, Feb 24, 2016 at 08:47:00AM +0100, Johannes Schindelin wrote:\n> \n> > \tI cannot think of a way how to test this: all of the regression\n> > \ttests run inside Git's own worktree, and we cannot even assume\n> > \tthat /tmp/ is outside of a worktree (or that it exists).\n> \n> We could make the test conditional on whether we are in a repo. Anybody\n> who builds from a tarball, or who uses --root would then run the test.\n\nCould we use GIT_CEILING_DIRECTORIES for this?  If it's set to\nTEST_OUTPUT_DIRECTORY won't that cover the in-tree and out-of-tree test\ncases?\n\nWe probably do still want Peff's REPOLESS prereq just in case someone is\ncollecting test results in a repository, but I think that will see much\nbetter coverage than relying on people running tests from the tarball.\n"},{"id":"279144","messageId":"20160224103152.GA21448@sigill.intra.peff.net","threadId":"41496","inReplyTo":"20160224101403.GN1766@serenity.lan","subject":"Re: [PATCH] git config: do not create .git/ if it does not exist yet","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-02-24T10:31:52Z","receivedAt":"2016-02-24T10:31:52Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 24, 2016 at 10:14:03AM +0000, John Keeping wrote:\n\n> On Wed, Feb 24, 2016 at 03:26:57AM -0500, Jeff King wrote:\n> > On Wed, Feb 24, 2016 at 08:47:00AM +0100, Johannes Schindelin wrote:\n> > \n> > > \tI cannot think of a way how to test this: all of the regression\n> > > \ttests run inside Git's own worktree, and we cannot even assume\n> > > \tthat /tmp/ is outside of a worktree (or that it exists).\n> > \n> > We could make the test conditional on whether we are in a repo. Anybody\n> > who builds from a tarball, or who uses --root would then run the test.\n> \n> Could we use GIT_CEILING_DIRECTORIES for this?  If it's set to\n> TEST_OUTPUT_DIRECTORY won't that cover the in-tree and out-of-tree test\n> cases?\n\nOh, right. That's much less nasty than my suggestion.\n\n> We probably do still want Peff's REPOLESS prereq just in case someone is\n> collecting test results in a repository,\n\nWe can create arbitrary hierarchies within the trash directory. So even\nwithout removing the trash-dir .git, we could probably do:\n\n  mkdir -p non-repo/foo &&\n  (\n\tcd non-repo &&\n\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n\texport GIT_CEILING_DIRECTORIES &&\n\tcd foo &&\n\tgit config foo.bar baz\n  )\n\nor something. That should work everywhere.\n\n> but I think that will see much\n> better coverage than relying on people running tests from the tarball.\n\nWith mine I think we'd see coverage from git devs, as it works with\n--root, too (and if you're not using --root with a RAM disk, I highly\nrecommend it for the speedup). But your suggestion is way better.\n\n-Peff\n"},{"id":"279147","messageId":"CACsJy8BETTY82RuEPD_Hthi3eXRK6WDutjO1RGscfCSun2SfUQ@mail.gmail.com","threadId":"41496","inReplyTo":"20160224082657.GD12511@sigill.intra.peff.net","subject":"Re: [PATCH] git config: do not create .git/ if it does not exist yet","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-02-24T11:01:15Z","receivedAt":"2016-02-24T11:01:15Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Feb 24, 2016 at 3:26 PM, Jeff King <peff@peff.net> wrote:\n> On Wed, Feb 24, 2016 at 08:47:00AM +0100, Johannes Schindelin wrote:\n>\n>> It is a pilot error to call `git config section.key value` outside of\n>> any Git worktree.\n>>\n>> Let's report that error instead of creating the .git/ directory and\n>> writing a fresh config into it.\n>\n> Hmm.  I get (on my Linux machine):\n>\n>   $ git config foo.bar baz\n>   error: could not lock config file .git/config: No such file or directory\n\nYep, tried the same thing before I asked about the .git dir thing on\ngfw list. Same result.\n\n> which makes sense (though still isn't a great error message, and is kind\n> of weird if you happen to have a .git directory that isn't a real\n> repository).\n\nKnown bug. If setup fails to find git dir and somebody (plenty of them\nin fact) calls get_git_dir(), we automtaically assume git dir is\n\".git\".\n\n> Is Git more aggressive about auto-creating the directory for lockfiles\n> on Windows? I tried the exact recipe you gave in the linked thread, just\n> to be sure, but I couldn't replicate it.\n\nIf .git is created before lockfile code, then the lock should be\nsuccessfully created.  The fix in check_write() fixes it for Johannes,\nso it must be something between\n\n// if (action == ACTION_SET) {...\ncheck_write();\ncheck_argc(argc, 2, 2);\nvalue = normalize_value(argv[0], argv[1]);\nret = git_config_set_in_file(given_config_source.file, argv[0], value);\n\nI don't see where mkdir() can be called either.\n\nJohannes, maybe you can force a crash in mingw_mkdir to pinpoint this\ncode? Just in case the bug is outside config code.\n-- \nDuy\n"},{"id":"279149","messageId":"alpine.DEB.2.20.1602241230120.3152@virtualbox","threadId":"41496","inReplyTo":"20160224103152.GA21448@sigill.intra.peff.net","subject":"Re: [PATCH] git config: do not create .git/ if it does not exist yet","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-24T11:31:11Z","receivedAt":"2016-02-24T11:31:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Peff, John & Junio (who recommended GIT_CEILING_DIRECTORIES first,\n\nOn Wed, 24 Feb 2016, Jeff King wrote:\n\n> On Wed, Feb 24, 2016 at 10:14:03AM +0000, John Keeping wrote:\n> \n> > On Wed, Feb 24, 2016 at 03:26:57AM -0500, Jeff King wrote:\n> > > On Wed, Feb 24, 2016 at 08:47:00AM +0100, Johannes Schindelin wrote:\n> > > \n> > > > \tI cannot think of a way how to test this: all of the regression\n> > > > \ttests run inside Git's own worktree, and we cannot even assume\n> > > > \tthat /tmp/ is outside of a worktree (or that it exists).\n> > > \n> > > We could make the test conditional on whether we are in a repo. Anybody\n> > > who builds from a tarball, or who uses --root would then run the test.\n> > \n> > Could we use GIT_CEILING_DIRECTORIES for this?\n\nAbsolutely. I created a test and essentially duplicated Peff's finding:\nthis is a Windows-only issue.\n\nWill keep you posted,\nDscho\n"},{"id":"279151","messageId":"alpine.DEB.2.20.1602241309560.3152@virtualbox","threadId":"41496","inReplyTo":"alpine.DEB.2.20.1602241230120.3152@virtualbox","subject":"Re: [PATCH] git config: do not create .git/ if it does not exist yet","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-24T12:13:39Z","receivedAt":"2016-02-24T12:13:39Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 24 Feb 2016, Johannes Schindelin wrote:\n\n> I created a test and essentially duplicated Peff's finding: this is a\n> Windows-only issue.\n\nIndeed it is in our patches:\n\n\thttps://github.com/git-for-windows/git/commit/3a4c37b22\n\n(short version: we carry some patches that simplify locking the config\nfile before building on top of it, and somehow we agreed back in the days\nwhen this patch was written that it would be a good idea if that code\ncreated leading directories.)\n\nI will fix this issue in Git for Windows, but I still think that my patch\nbrings a usability improvement: the error message is just so much more to\nthe point (will submit v2 in a moment).\n\nCiao,\nDscho\n"},{"id":"279152","messageId":"20160224123444.GA27909@sigill.intra.peff.net","threadId":"41496","inReplyTo":"alpine.DEB.2.20.1602241309560.3152@virtualbox","subject":"Re: [PATCH] git config: do not create .git/ if it does not exist yet","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-02-24T12:34:44Z","receivedAt":"2016-02-24T12:34:44Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 24, 2016 at 01:13:39PM +0100, Johannes Schindelin wrote:\n\n> > I created a test and essentially duplicated Peff's finding: this is a\n> > Windows-only issue.\n> \n> Indeed it is in our patches:\n> \n> \thttps://github.com/git-for-windows/git/commit/3a4c37b22\n> \n> (short version: we carry some patches that simplify locking the config\n> file before building on top of it, and somehow we agreed back in the days\n> when this patch was written that it would be a good idea if that code\n> created leading directories.)\n\nThanks for tracking it down.\n\n> I will fix this issue in Git for Windows, but I still think that my patch\n> brings a usability improvement: the error message is just so much more to\n> the point (will submit v2 in a moment).\n\nYeah, I agree it is still worth doing.\n\n-Peff\n"},{"id":"279153","messageId":"b225aec8c83a184f90dc6bfa821177b52ef4b3f4.1456318031.git.johannes.schindelin@gmx.de","threadId":"41496","inReplyTo":"c4027d758b0914dbc2e1ff5df344b0669aac4447.1456299545.git.johannes.schindelin@gmx.de","subject":"[PATCH v2] git config: report when trying to modify a non-existing repo config","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-24T12:48:11Z","receivedAt":"2016-02-24T12:48:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"It is a pilot error to call `git config section.key value` outside of\nany Git worktree. The message\n\n\terror: could not lock config file .git/config: No such file or\n\tdirectory\n\nis not very helpful in that situation, though. Let's print a helpful\nmessage instead.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/config.c      | 3 +++\n t/t1308-config-set.sh | 9 +++++++++\n 2 files changed, 12 insertions(+)\n\nThe commit message was adjusted to reflect that this is not a bug fix\n(except for Git for Windows), and a test was added.\n\nInterdiff vs v1:\n\n diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh\n index 91235b7..f62409e 100755\n --- a/t/t1308-config-set.sh\n +++ b/t/t1308-config-set.sh\n @@ -218,4 +218,13 @@ test_expect_success 'check line errors for malformed values' '\n  \ttest_i18ngrep \"fatal: .*alias\\.br.*\\.git/config.*line 2\" result\n  '\n  \n +test_expect_success 'error on modifying repo config without repo' '\n +\tmkdir no-repo &&\n +\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n +\texport GIT_CEILING_DIRECTORIES &&\n +\tcd no-repo &&\n +\ttest_must_fail git config a.b c 2>err &&\n +\tgrep \"not in a git directory\" err\n +'\n +\n  test_done\n\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex adc7727..78aab95 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -352,6 +352,9 @@ static int get_colorbool(const char *var, int print)\n \n static void check_write(void)\n {\n+\tif (!given_config_source.file && !startup_info->have_repository)\n+\t\tdie(\"not in a git directory\");\n+\n \tif (given_config_source.use_stdin)\n \t\tdie(\"writing to stdin is not supported\");\n \ndiff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh\nindex 91235b7..f62409e 100755\n--- a/t/t1308-config-set.sh\n+++ b/t/t1308-config-set.sh\n@@ -218,4 +218,13 @@ test_expect_success 'check line errors for malformed values' '\n \ttest_i18ngrep \"fatal: .*alias\\.br.*\\.git/config.*line 2\" result\n '\n \n+test_expect_success 'error on modifying repo config without repo' '\n+\tmkdir no-repo &&\n+\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n+\texport GIT_CEILING_DIRECTORIES &&\n+\tcd no-repo &&\n+\ttest_must_fail git config a.b c 2>err &&\n+\tgrep \"not in a git directory\" err\n+'\n+\n test_done\n-- \n2.7.2.windows.1.2.gbc859c8\n"},{"id":"279155","messageId":"20160224125930.GA1422@lanh","threadId":"41496","inReplyTo":"b225aec8c83a184f90dc6bfa821177b52ef4b3f4.1456318031.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH v2] git config: report when trying to modify a non-existing repo config","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-02-24T12:59:30Z","receivedAt":"2016-02-24T12:59:30Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Feb 24, 2016 at 01:48:11PM +0100, Johannes Schindelin wrote:\n> +\t\tdie(\"not in a git directory\");\n\nMaybe wrap this string with _() for translation? Then we can pile this\npatch on top to fix the rest in builtin/config.c.\n\n-- 8< --\nSubject: [PATCH] builtin/config.c: mark strings for translation\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/config.c | 41 +++++++++++++++++++++--------------------\n 1 file changed, 21 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex adc7727..7dad412 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -87,7 +87,7 @@ static struct option builtin_config_options[] = {\n static void check_argc(int argc, int min, int max) {\n \tif (argc >= min && argc <= max)\n \t\treturn;\n-\terror(\"wrong number of arguments\");\n+\terror(_(\"wrong number of arguments\"));\n \tusage_with_options(builtin_config_usage, builtin_config_options);\n }\n \n@@ -188,7 +188,7 @@ static int get_value(const char *key_, const char *regex_)\n \n \t\tkey_regexp = (regex_t*)xmalloc(sizeof(regex_t));\n \t\tif (regcomp(key_regexp, key, REG_EXTENDED)) {\n-\t\t\terror(\"invalid key pattern: %s\", key_);\n+\t\t\terror(_(\"invalid key pattern: %s\"), key_);\n \t\t\tfree(key_regexp);\n \t\t\tkey_regexp = NULL;\n \t\t\tret = CONFIG_INVALID_PATTERN;\n@@ -209,7 +209,7 @@ static int get_value(const char *key_, const char *regex_)\n \n \t\tregexp = (regex_t*)xmalloc(sizeof(regex_t));\n \t\tif (regcomp(regexp, regex_, REG_EXTENDED)) {\n-\t\t\terror(\"invalid pattern: %s\", regex_);\n+\t\t\terror(_(\"invalid pattern: %s\"), regex_);\n \t\t\tfree(regexp);\n \t\t\tregexp = NULL;\n \t\t\tret = CONFIG_INVALID_PATTERN;\n@@ -353,10 +353,10 @@ static int get_colorbool(const char *var, int print)\n static void check_write(void)\n {\n \tif (given_config_source.use_stdin)\n-\t\tdie(\"writing to stdin is not supported\");\n+\t\tdie(_(\"writing to stdin is not supported\"));\n \n \tif (given_config_source.blob)\n-\t\tdie(\"writing config blobs is not supported\");\n+\t\tdie(_(\"writing config blobs is not supported\"));\n }\n \n struct urlmatch_current_candidate_value {\n@@ -461,7 +461,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \n \tif (use_global_config + use_system_config + use_local_config +\n \t    !!given_config_source.file + !!given_config_source.blob > 1) {\n-\t\terror(\"only one config file at a time.\");\n+\t\terror(_(\"only one config file at a time.\"));\n \t\tusage_with_options(builtin_config_usage, builtin_config_options);\n \t}\n \n@@ -482,7 +482,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t\t * location; error out even if XDG_CONFIG_HOME\n \t\t\t * is set and points at a sane location.\n \t\t\t */\n-\t\t\tdie(\"$HOME not set\");\n+\t\t\tdie(_(\"$HOME not set\"));\n \n \t\tif (access_or_warn(user_config, R_OK, 0) &&\n \t\t    xdg_config && !access_or_warn(xdg_config, R_OK, 0))\n@@ -512,17 +512,17 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (HAS_MULTI_BITS(types)) {\n-\t\terror(\"only one type at a time.\");\n+\t\terror(_(\"only one type at a time.\"));\n \t\tusage_with_options(builtin_config_usage, builtin_config_options);\n \t}\n \n \tif ((actions & (ACTION_GET_COLOR|ACTION_GET_COLORBOOL)) && types) {\n-\t\terror(\"--get-color and variable type are incoherent\");\n+\t\terror(_(\"--get-color and variable type are incoherent\"));\n \t\tusage_with_options(builtin_config_usage, builtin_config_options);\n \t}\n \n \tif (HAS_MULTI_BITS(actions)) {\n-\t\terror(\"only one action at a time.\");\n+\t\terror(_(\"only one action at a time.\"));\n \t\tusage_with_options(builtin_config_usage, builtin_config_options);\n \t}\n \tif (actions == 0)\n@@ -535,7 +535,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t}\n \tif (omit_values &&\n \t    !(actions == ACTION_LIST || actions == ACTION_GET_REGEXP)) {\n-\t\terror(\"--name-only is only applicable to --list or --get-regexp\");\n+\t\terror(_(\"--name-only is only applicable to --list or --get-regexp\"));\n \t\tusage_with_options(builtin_config_usage, builtin_config_options);\n \t}\n \tif (actions == ACTION_LIST) {\n@@ -544,10 +544,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t\t\t\t    &given_config_source,\n \t\t\t\t\t    respect_includes) < 0) {\n \t\t\tif (given_config_source.file)\n-\t\t\t\tdie_errno(\"unable to read config file '%s'\",\n+\t\t\t\tdie_errno(_(\"unable to read config file '%s'\"),\n \t\t\t\t\t  given_config_source.file);\n \t\t\telse\n-\t\t\t\tdie(\"error processing config file(s)\");\n+\t\t\t\tdie(_(\"error processing config file(s)\"));\n \t\t}\n \t}\n \telse if (actions == ACTION_EDIT) {\n@@ -555,11 +555,11 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \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+\t\t\tdie(_(\"not in a git directory\"));\n \t\tif (given_config_source.use_stdin)\n-\t\t\tdie(\"editing stdin is not supported\");\n+\t\t\tdie(_(\"editing stdin is not supported\"));\n \t\tif (given_config_source.blob)\n-\t\t\tdie(\"editing blobs is not supported\");\n+\t\t\tdie(_(\"editing blobs is not supported\"));\n \t\tgit_config(git_default_config, NULL);\n \t\tconfig_file = xstrdup(given_config_source.file ?\n \t\t\t\t      given_config_source.file : git_path(\"config\"));\n@@ -584,8 +584,9 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\tvalue = normalize_value(argv[0], argv[1]);\n \t\tret = git_config_set_in_file(given_config_source.file, argv[0], value);\n \t\tif (ret == CONFIG_NOTHING_SET)\n-\t\t\terror(\"cannot overwrite multiple values with a single value\\n\"\n-\t\t\t\"       Use a regexp, --add or --replace-all to change %s.\", argv[0]);\n+\t\t\terror(_(\"cannot overwrite multiple values with a single value\\n\"\n+\t\t\t\t\"Use a regexp, --add or --replace-all to change %s.\"),\n+\t\t\t      argv[0]);\n \t\treturn ret;\n \t}\n \telse if (actions == ACTION_SET_ALL) {\n@@ -655,7 +656,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\tif (ret < 0)\n \t\t\treturn ret;\n \t\tif (ret == 0)\n-\t\t\tdie(\"No such section!\");\n+\t\t\tdie(_(\"No such section!\"));\n \t}\n \telse if (actions == ACTION_REMOVE_SECTION) {\n \t\tint ret;\n@@ -666,7 +667,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\tif (ret < 0)\n \t\t\treturn ret;\n \t\tif (ret == 0)\n-\t\t\tdie(\"No such section!\");\n+\t\t\tdie(_(\"No such section!\"));\n \t}\n \telse if (actions == ACTION_GET_COLOR) {\n \t\tcheck_argc(argc, 1, 2);\n-- \n2.7.2.531.gc9e018c\n\n-- 8< --\n"},{"id":"279157","messageId":"alpine.DEB.2.20.1602241425180.3152@virtualbox","threadId":"41496","inReplyTo":"20160224125930.GA1422@lanh","subject":"Re: [PATCH v2] git config: report when trying to modify a non-existing repo config","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-24T13:26:06Z","receivedAt":"2016-02-24T13:26:06Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Duy,\n\nOn Wed, 24 Feb 2016, Duy Nguyen wrote:\n\n> On Wed, Feb 24, 2016 at 01:48:11PM +0100, Johannes Schindelin wrote:\n> > +\t\tdie(\"not in a git directory\");\n> \n> Maybe wrap this string with _() for translation? Then we can pile this\n> patch on top to fix the rest in builtin/config.c.\n\nGiven that the context lines contain die() calls *without* _(), I would\nfind it more logical if your patch patched also the line I introduced,\ntogether with the other die() calls.\n\nCiao,\nDscho\n"},{"id":"279160","messageId":"CACsJy8CuLPCYAtNn4u-RYHhL=LqGJH_GFNwbAWHxfdAximLtug@mail.gmail.com","threadId":"41496","inReplyTo":"alpine.DEB.2.20.1602241425180.3152@virtualbox","subject":"Re: [PATCH v2] git config: report when trying to modify a non-existing repo config","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-02-24T13:29:59Z","receivedAt":"2016-02-24T13:29:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Feb 24, 2016 at 8:26 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi Duy,\n>\n> On Wed, 24 Feb 2016, Duy Nguyen wrote:\n>\n>> On Wed, Feb 24, 2016 at 01:48:11PM +0100, Johannes Schindelin wrote:\n>> > +           die(\"not in a git directory\");\n>>\n>> Maybe wrap this string with _() for translation? Then we can pile this\n>> patch on top to fix the rest in builtin/config.c.\n>\n> Given that the context lines contain die() calls *without* _(), I would\n> find it more logical if your patch patched also the line I introduced,\n> together with the other die() calls.\n\nNo problem. I'll go over all changes in 'next' and 'pu' some time\nlater and try to fix them all.\n-- \nDuy\n"},{"id":"279164","messageId":"xmqqio1et0a3.fsf@gitster.mtv.corp.google.com","threadId":"41496","inReplyTo":"alpine.DEB.2.20.1602241309560.3152@virtualbox","subject":"Re: [PATCH] git config: do not create .git/ if it does not exist yet","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-24T18:45:40Z","receivedAt":"2016-02-24T18:45:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi,\n>\n> On Wed, 24 Feb 2016, Johannes Schindelin wrote:\n>\n>> I created a test and essentially duplicated Peff's finding: this is a\n>> Windows-only issue.\n>\n> Indeed it is in our patches:\n>\n> \thttps://github.com/git-for-windows/git/commit/3a4c37b22\n>\n> (short version: we carry some patches that simplify locking the config\n> file before building on top of it, and somehow we agreed back in the days\n> when this patch was written that it would be a good idea if that code\n> created leading directories.)\n\nThe log message there says this:\n\n    This is particularly important when calling\n\n         git config -f /non/existing/directory/config ...\n\nI think that the change should be ejected.\n\n\tcat >/non/existing/directory/file\n\tmkdir /non/existing/directory/dir\n\nwould fail, and I do not see any valid reason for \"git config\" to be\ndifferent.\n\n> I will fix this issue in Git for Windows, but I still think that my patch\n> brings a usability improvement: the error message is just so much more to\n> the point (will submit v2 in a moment).\n\nThanks.  I think your patch in this thread is an improvement.\n"},{"id":"279170","messageId":"xmqq60xduauv.fsf@gitster.mtv.corp.google.com","threadId":"41496","inReplyTo":"b225aec8c83a184f90dc6bfa821177b52ef4b3f4.1456318031.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH v2] git config: report when trying to modify a non-existing repo config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-24T20:11:52Z","receivedAt":"2016-02-24T20:11:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n\n> diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh\n> index 91235b7..f62409e 100755\n> --- a/t/t1308-config-set.sh\n> +++ b/t/t1308-config-set.sh\n> @@ -218,4 +218,13 @@ test_expect_success 'check line errors for malformed values' '\n>  \ttest_i18ngrep \"fatal: .*alias\\.br.*\\.git/config.*line 2\" result\n>  '\n>  \n> +test_expect_success 'error on modifying repo config without repo' '\n> +\tmkdir no-repo &&\n> +\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n> +\texport GIT_CEILING_DIRECTORIES &&\n> +\tcd no-repo &&\n> +\ttest_must_fail git config a.b c 2>err &&\n> +\tgrep \"not in a git directory\" err\n> +'\n> +\n>  test_done\n\nPlease make it a habit to run tests that go up/down in the hierarchy\nin a subshell.  It is not a good excuse that this new test happens\nto be at the end _right now_.\n"},{"id":"279187","messageId":"xmqqlh69spt4.fsf@gitster.mtv.corp.google.com","threadId":"41496","inReplyTo":"xmqq60xduauv.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] git config: report when trying to modify a non-existing repo config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-24T22:31:51Z","receivedAt":"2016-02-24T22:31:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n>\n>> diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh\n>> index 91235b7..f62409e 100755\n>> --- a/t/t1308-config-set.sh\n>> +++ b/t/t1308-config-set.sh\n>> @@ -218,4 +218,13 @@ test_expect_success 'check line errors for malformed values' '\n>>  \ttest_i18ngrep \"fatal: .*alias\\.br.*\\.git/config.*line 2\" result\n>>  '\n>>  \n>> +test_expect_success 'error on modifying repo config without repo' '\n>> +\tmkdir no-repo &&\n>> +\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n>> +\texport GIT_CEILING_DIRECTORIES &&\n>> +\tcd no-repo &&\n>> +\ttest_must_fail git config a.b c 2>err &&\n>> +\tgrep \"not in a git directory\" err\n>> +'\n>> +\n>>  test_done\n>\n> Please make it a habit to run tests that go up/down in the hierarchy\n> in a subshell.  It is not a good excuse that this new test happens\n> to be at the end _right now_.\n\nI'd squash this in.\n\nThanks.\n\n t/t1308-config-set.sh | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh\nindex f62409e..9863d0d 100755\n--- a/t/t1308-config-set.sh\n+++ b/t/t1308-config-set.sh\n@@ -220,11 +220,13 @@ test_expect_success 'check line errors for malformed values' '\n \n test_expect_success 'error on modifying repo config without repo' '\n \tmkdir no-repo &&\n-\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n-\texport GIT_CEILING_DIRECTORIES &&\n-\tcd no-repo &&\n-\ttest_must_fail git config a.b c 2>err &&\n-\tgrep \"not in a git directory\" err\n+\t(\n+\t\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n+\t\texport GIT_CEILING_DIRECTORIES &&\n+\t\tcd no-repo &&\n+\t\ttest_must_fail git config a.b c 2>err &&\n+\t\tgrep \"not in a git directory\" err\n+\t)\n '\n \n test_done\n"},{"id":"279342","messageId":"alpine.DEB.2.20.1602251654160.3152@virtualbox","threadId":"41496","inReplyTo":"xmqqlh69spt4.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] git config: report when trying to modify a non-existing repo config","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-25T15:54:48Z","receivedAt":"2016-02-25T15:54:48Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Wed, 24 Feb 2016, Junio C Hamano wrote:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n> > Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n> >\n> >> diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh\n> >> index 91235b7..f62409e 100755\n> >> --- a/t/t1308-config-set.sh\n> >> +++ b/t/t1308-config-set.sh\n> >> @@ -218,4 +218,13 @@ test_expect_success 'check line errors for malformed values' '\n> >>  \ttest_i18ngrep \"fatal: .*alias\\.br.*\\.git/config.*line 2\" result\n> >>  '\n> >>  \n> >> +test_expect_success 'error on modifying repo config without repo' '\n> >> +\tmkdir no-repo &&\n> >> +\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n> >> +\texport GIT_CEILING_DIRECTORIES &&\n> >> +\tcd no-repo &&\n> >> +\ttest_must_fail git config a.b c 2>err &&\n> >> +\tgrep \"not in a git directory\" err\n> >> +'\n> >> +\n> >>  test_done\n> >\n> > Please make it a habit to run tests that go up/down in the hierarchy\n> > in a subshell.  It is not a good excuse that this new test happens\n> > to be at the end _right now_.\n> \n> I'd squash this in.\n\nPlease do, unless you want me to resend with the squashed commit (I picked\nup the change from your 'pu' branch)?\n\nCiao,\nDscho\n"}]}