{"thread":{"id":"50678","subject":"[PATCH 0/1] Fix git init with core.hidedotfiles","startedAt":"2019-03-07T09:35:44Z","lastAt":"2019-03-11T20:12:04Z","messageCount":6,"participants":["Johannes Schindelin via GitGitGadget","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"370884","messageId":"pull.131.git.gitgitgadget@gmail.com","threadId":"50678","inReplyTo":null,"subject":"[PATCH 0/1] Fix git init with core.hidedotfiles","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-03-07T09:35:40Z","receivedAt":"2019-03-07T09:35:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"This fixes an regression that was not present in Git for Windows's original \ncore.hideDotFiles patch, but in the shape of the core.hideDotFiles patch\nthat made it into git.git.\n\nWe fixed it in one big hurry in Git for Windows, and I simply forgot to\nupstream this right away.\n\nJohannes Schindelin (1):\n  mingw: respect core.hidedotfiles = false in git-init again\n\n builtin/init-db.c |  6 ++++++\n t/t0001-init.sh   | 12 ++++++++++++\n 2 files changed, 18 insertions(+)\n\n\nbase-commit: 39ffebd23b1ef6830bf86043ef0b5c069d9299a9\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-131%2Fdscho%2Funhidden-git-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-131/dscho/unhidden-git-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/131\n-- \ngitgitgadget\n"},{"id":"370885","messageId":"008e367d26de12debd596e8f16356f70c74d3d7e.1551951339.git.gitgitgadget@gmail.com","threadId":"50678","inReplyTo":"pull.131.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-03-07T09:35:40Z","receivedAt":"2019-03-07T09:35:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThis is a brown paper bag. When adding the tests, we actually failed\nto verify that the config variable is heeded in git-init at all. And\nwhen changing the original patch that marked the .git/ directory as\nhidden after reading the config, it was lost on this developer that\nthe new code would use the hide_dotfiles variable before the config\nwas read.\n\nThe fix is obvious: read the (limited, pre-init) config *before*\ncreating the .git/ directory.\n\nThis fixes https://github.com/git-for-windows/git/issues/789\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/init-db.c |  6 ++++++\n t/t0001-init.sh   | 12 ++++++++++++\n 2 files changed, 18 insertions(+)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 93eff7618c..94df241ad5 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -155,6 +155,9 @@ static int git_init_db_config(const char *k, const char *v, void *cb)\n \tif (!strcmp(k, \"init.templatedir\"))\n \t\treturn git_config_pathname(&init_db_template_dir, k, v);\n \n+\tif (starts_with(k, \"core.\"))\n+\t\treturn platform_core_config(k, v, cb);\n+\n \treturn 0;\n }\n \n@@ -361,6 +364,9 @@ int init_db(const char *git_dir, const char *real_git_dir,\n \t}\n \tstartup_info->have_repository = 1;\n \n+\t/* Just look for `init.templatedir` and `core.hidedotfiles` */\n+\tgit_config(git_init_db_config, NULL);\n+\n \tsafe_create_dir(git_dir, 0);\n \n \tinit_is_bare_repository = is_bare_repository();\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 42a263cada..35ede1b0b0 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -453,6 +453,18 @@ test_expect_success 're-init from a linked worktree' '\n \t)\n '\n \n+test_expect_success MINGW 'core.hidedotfiles = false' '\n+\tgit config --global core.hidedotfiles false &&\n+\trm -rf newdir &&\n+\t(\n+\t\tsane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&\n+\t\tmkdir newdir &&\n+\t\tcd newdir &&\n+\t\tgit init\n+\t) &&\n+\t! is_hidden newdir/.git\n+'\n+\n test_expect_success MINGW 'redirect std handles' '\n \tGIT_REDIRECT_STDOUT=output.txt git rev-parse --git-dir &&\n \ttest .git = \"$(cat output.txt)\" &&\n-- \ngitgitgadget\n"},{"id":"370939","messageId":"xmqqva0ujboi.fsf@gitster-ct.c.googlers.com","threadId":"50678","inReplyTo":"008e367d26de12debd596e8f16356f70c74d3d7e.1551951339.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-03-08T03:18:53Z","receivedAt":"2019-03-08T03:18:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> diff --git a/builtin/init-db.c b/builtin/init-db.c\n> index 93eff7618c..94df241ad5 100644\n> --- a/builtin/init-db.c\n> +++ b/builtin/init-db.c\n> @@ -155,6 +155,9 @@ static int git_init_db_config(const char *k, const char *v, void *cb)\n>  \tif (!strcmp(k, \"init.templatedir\"))\n>  \t\treturn git_config_pathname(&init_db_template_dir, k, v);\n>  \n> +\tif (starts_with(k, \"core.\"))\n> +\t\treturn platform_core_config(k, v, cb);\n> +\n>  \treturn 0;\n>  }\n\nOK.  I think this is very much futureproof and a sensible thing to\nhave a \"platform_core_config()\" call here.  That way, we do not have\nto say the details of what platform specific thing each platform\nwants when init_db_config works.\n\n> @@ -361,6 +364,9 @@ int init_db(const char *git_dir, const char *real_git_dir,\n>  \t}\n>  \tstartup_info->have_repository = 1;\n>  \n> +\t/* Just look for `init.templatedir` and `core.hidedotfiles` */\n\nAnd from that point of view, replacing `core.hidedotfiles` with\nsomething like \"platform specific core config\" would be more\nappropriate.\n\n> +\tgit_config(git_init_db_config, NULL);\n> +\n\nWe use git_init_db_config from create_default_files(), which is a\nfunction called several lines after this point; shouldn't that now\nbe removed from create_default_files()?\n\n>  \tsafe_create_dir(git_dir, 0);\n>  \n>  \tinit_is_bare_repository = is_bare_repository();\n> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> index 42a263cada..35ede1b0b0 100755\n> --- a/t/t0001-init.sh\n> +++ b/t/t0001-init.sh\n> @@ -453,6 +453,18 @@ test_expect_success 're-init from a linked worktree' '\n>  \t)\n>  '\n>  \n> +test_expect_success MINGW 'core.hidedotfiles = false' '\n> +\tgit config --global core.hidedotfiles false &&\n> +\trm -rf newdir &&\n> +\t(\n> +\t\tsane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&\n> +\t\tmkdir newdir &&\n> +\t\tcd newdir &&\n> +\t\tgit init\n> +\t) &&\n\nThis is not incorrect per-se, but I think most tests do the mkdir\noutside subshell, i.e.\n\n\trm -rf newdir &&\n\tmkdir newdir &&\n\t(\n\t\tcd newdir &&\n\t\tsane_unset ... &&\n\t\t...\n\t) &&\n\nOther than these, I find nothing questionable in the patch.  Nicely\ndone.\n\n\n"},{"id":"371186","messageId":"nycvar.QRO.7.76.6.1903112037070.41@tvgsbejvaqbjf.bet","threadId":"50678","inReplyTo":"xmqqva0ujboi.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 1/1] mingw: respect core.hidedotfiles = false in git-init again","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-03-11T19:56:10Z","receivedAt":"2019-03-11T20:10:34Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Fri, 8 Mar 2019, Junio C Hamano wrote:\n\n> \"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\n> writes:\n> \n> > diff --git a/builtin/init-db.c b/builtin/init-db.c\n> > index 93eff7618c..94df241ad5 100644\n> > --- a/builtin/init-db.c\n> > +++ b/builtin/init-db.c\n> > @@ -155,6 +155,9 @@ static int git_init_db_config(const char *k, const char *v, void *cb)\n> >  \tif (!strcmp(k, \"init.templatedir\"))\n> >  \t\treturn git_config_pathname(&init_db_template_dir, k, v);\n> >  \n> > +\tif (starts_with(k, \"core.\"))\n> > +\t\treturn platform_core_config(k, v, cb);\n> > +\n> >  \treturn 0;\n> >  }\n> \n> OK.  I think this is very much futureproof and a sensible thing to\n> have a \"platform_core_config()\" call here.  That way, we do not have\n> to say the details of what platform specific thing each platform\n> wants when init_db_config works.\n\nI am glad you agree.\n\n> > @@ -361,6 +364,9 @@ int init_db(const char *git_dir, const char *real_git_dir,\n> >  \t}\n> >  \tstartup_info->have_repository = 1;\n> >  \n> > +\t/* Just look for `init.templatedir` and `core.hidedotfiles` */\n> \n> And from that point of view, replacing `core.hidedotfiles` with\n> something like \"platform specific core config\" would be more\n> appropriate.\n\nProbably. But it could potentially make some developer (such as myself,\nsix months from now) wonder why we don't just remove this call because\nclearly nothing uses this on Linux.\n\nSo even if it is not quite future-proof from the point of view where we\n*technically* would have to extend this comment if we ever introduced\nanother platform-specific config setting that is relevant to the early\nphase of `git init`, I would like to keep the comment in the current form.\n\nWell, actually *almost* in the current form.\n\nI did realize, based on your comment below, that the mention of\n`init.templatedir` here is bogus, wrong even: if `git init` is started in\na Git worktree, we do not *want* to use the `init.templatedir` setting\nfrom said worktree.\n\nAnd that is the reason why...\n\n> > +\tgit_config(git_init_db_config, NULL);\n> > +\n> \n> We use git_init_db_config from create_default_files(), which is a\n> function called several lines after this point; shouldn't that now\n> be removed from create_default_files()?\n\n... we have to call `git_config()` *again* in `create_default_files()`.\n\n> >  \tsafe_create_dir(git_dir, 0);\n> >  \n> >  \tinit_is_bare_repository = is_bare_repository();\n> > diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> > index 42a263cada..35ede1b0b0 100755\n> > --- a/t/t0001-init.sh\n> > +++ b/t/t0001-init.sh\n> > @@ -453,6 +453,18 @@ test_expect_success 're-init from a linked worktree' '\n> >  \t)\n> >  '\n> >  \n> > +test_expect_success MINGW 'core.hidedotfiles = false' '\n> > +\tgit config --global core.hidedotfiles false &&\n> > +\trm -rf newdir &&\n> > +\t(\n> > +\t\tsane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&\n> > +\t\tmkdir newdir &&\n> > +\t\tcd newdir &&\n> > +\t\tgit init\n> > +\t) &&\n> \n> This is not incorrect per-se, but I think most tests do the mkdir\n> outside subshell, i.e.\n> \n> \trm -rf newdir &&\n> \tmkdir newdir &&\n> \t(\n> \t\tcd newdir &&\n> \t\tsane_unset ... &&\n> \t\t...\n> \t) &&\n\nLegit.\n\nThanks,\nDscho\n\n> \n> Other than these, I find nothing questionable in the patch.  Nicely\n> done.\n> \n> \n> \n"},{"id":"371187","messageId":"pull.131.v2.git.gitgitgadget@gmail.com","threadId":"50678","inReplyTo":"pull.131.git.gitgitgadget@gmail.com","subject":"[PATCH v2 0/1] Fix git init with core.hidedotfiles","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-03-11T20:10:57Z","receivedAt":"2019-03-11T20:11:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"This fixes an regression that was not present in Git for Windows's original \ncore.hideDotFiles patch, but in the shape of the core.hideDotFiles patch\nthat made it into git.git.\n\nWe fixed it in one big hurry in Git for Windows, and I simply forgot to\nupstream this right away.\n\nChanges since v1:\n\n * Clarified in the code comment that our intention is to pick up \n   core.hidedotfiles in the first git_config() call.\n * Explained in the commit message why we cannot remove the \n   git_config(git_init_db_config, NULL) call from create_default_files(): it\n   would cause a change of behavior with regard to the init.templatedir \n   setting.\n * Simplified the test case.\n\nJohannes Schindelin (1):\n  mingw: respect core.hidedotfiles = false in git-init again\n\n builtin/init-db.c |  7 +++++++\n t/t0001-init.sh   | 11 +++++++++++\n 2 files changed, 18 insertions(+)\n\n\nbase-commit: e902e9bcae2010bc42648c80ab6adc6c5a16a4a5\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-131%2Fdscho%2Funhidden-git-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-131/dscho/unhidden-git-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/131\n\nRange-diff vs v1:\n\n 1:  008e367d26 ! 1:  f187d0d247 mingw: respect core.hidedotfiles = false in git-init again\n     @@ -12,6 +12,12 @@\n          The fix is obvious: read the (limited, pre-init) config *before*\n          creating the .git/ directory.\n      \n     +    Please note that we cannot remove the identical-looking `git_config()`\n     +    call from `create_default_files()`: we create the `.git/` directory\n     +    between those calls. If we removed it, and if the parent directory is\n     +    in a Git worktree, and if that worktree's `.git/config` contained any\n     +    `init.templatedir` setting, we would all of a sudden pick that up.\n     +\n          This fixes https://github.com/git-for-windows/git/issues/789\n      \n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n     @@ -29,11 +35,19 @@\n       \treturn 0;\n       }\n       \n     +@@\n     + \tstruct strbuf err = STRBUF_INIT;\n     + \n     + \t/* Just look for `init.templatedir` */\n     ++\tinit_db_template_dir = NULL; /* re-set in case it was set before */\n     + \tgit_config(git_init_db_config, NULL);\n     + \n     + \t/*\n      @@\n       \t}\n       \tstartup_info->have_repository = 1;\n       \n     -+\t/* Just look for `init.templatedir` and `core.hidedotfiles` */\n     ++\t/* Just look for `core.hidedotfiles` */\n      +\tgit_config(git_init_db_config, NULL);\n      +\n       \tsafe_create_dir(git_dir, 0);\n     @@ -50,11 +64,10 @@\n      +test_expect_success MINGW 'core.hidedotfiles = false' '\n      +\tgit config --global core.hidedotfiles false &&\n      +\trm -rf newdir &&\n     ++\tmkdir newdir &&\n      +\t(\n      +\t\tsane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&\n     -+\t\tmkdir newdir &&\n     -+\t\tcd newdir &&\n     -+\t\tgit init\n     ++\t\tgit -C newdir init\n      +\t) &&\n      +\t! is_hidden newdir/.git\n      +'\n\n-- \ngitgitgadget\n"},{"id":"371188","messageId":"f187d0d247bf0523b63c265cd01116646597eb28.1552335057.git.gitgitgadget@gmail.com","threadId":"50678","inReplyTo":"pull.131.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 1/1] mingw: respect core.hidedotfiles = false in git-init again","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-03-11T20:10:58Z","receivedAt":"2019-03-11T20:12:04Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThis is a brown paper bag. When adding the tests, we actually failed\nto verify that the config variable is heeded in git-init at all. And\nwhen changing the original patch that marked the .git/ directory as\nhidden after reading the config, it was lost on this developer that\nthe new code would use the hide_dotfiles variable before the config\nwas read.\n\nThe fix is obvious: read the (limited, pre-init) config *before*\ncreating the .git/ directory.\n\nPlease note that we cannot remove the identical-looking `git_config()`\ncall from `create_default_files()`: we create the `.git/` directory\nbetween those calls. If we removed it, and if the parent directory is\nin a Git worktree, and if that worktree's `.git/config` contained any\n`init.templatedir` setting, we would all of a sudden pick that up.\n\nThis fixes https://github.com/git-for-windows/git/issues/789\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/init-db.c |  7 +++++++\n t/t0001-init.sh   | 11 +++++++++++\n 2 files changed, 18 insertions(+)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 93eff7618c..190754ba39 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -155,6 +155,9 @@ static int git_init_db_config(const char *k, const char *v, void *cb)\n \tif (!strcmp(k, \"init.templatedir\"))\n \t\treturn git_config_pathname(&init_db_template_dir, k, v);\n \n+\tif (starts_with(k, \"core.\"))\n+\t\treturn platform_core_config(k, v, cb);\n+\n \treturn 0;\n }\n \n@@ -185,6 +188,7 @@ static int create_default_files(const char *template_path,\n \tstruct strbuf err = STRBUF_INIT;\n \n \t/* Just look for `init.templatedir` */\n+\tinit_db_template_dir = NULL; /* re-set in case it was set before */\n \tgit_config(git_init_db_config, NULL);\n \n \t/*\n@@ -361,6 +365,9 @@ int init_db(const char *git_dir, const char *real_git_dir,\n \t}\n \tstartup_info->have_repository = 1;\n \n+\t/* Just look for `core.hidedotfiles` */\n+\tgit_config(git_init_db_config, NULL);\n+\n \tsafe_create_dir(git_dir, 0);\n \n \tinit_is_bare_repository = is_bare_repository();\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 5e27604b24..1f462204ea 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -454,6 +454,17 @@ test_expect_success 're-init from a linked worktree' '\n \t)\n '\n \n+test_expect_success MINGW 'core.hidedotfiles = false' '\n+\tgit config --global core.hidedotfiles false &&\n+\trm -rf newdir &&\n+\tmkdir newdir &&\n+\t(\n+\t\tsane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&\n+\t\tgit -C newdir init\n+\t) &&\n+\t! is_hidden newdir/.git\n+'\n+\n test_expect_success MINGW 'redirect std handles' '\n \tGIT_REDIRECT_STDOUT=output.txt git rev-parse --git-dir &&\n \ttest .git = \"$(cat output.txt)\" &&\n-- \ngitgitgadget\n"}]}