{"thread":{"id":"58707","subject":"[PATCH 2/2] help.c: don't call git_default_config in git_unknown_cmd_config","startedAt":"2022-10-28T15:24:16Z","lastAt":"2022-12-13T09:48:50Z","messageCount":9,"participants":["Simon Gerber via GitGitGadget","Junio C Hamano","Simon Gerber"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"465950","messageId":"7a2bef324395ff8aba83564fb33df2e090bde278.1666970645.git.gitgitgadget@gmail.com","threadId":"58707","inReplyTo":"pull.1373.git.git.1666970645.gitgitgadget@gmail.com","subject":"[PATCH 2/2] help.c: don't call git_default_config in git_unknown_cmd_config","fromName":"Simon Gerber via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-10-28T15:24:05Z","receivedAt":"2022-10-28T15:24:16Z","isPatch":true,"sender":{"key":"gesimu@gmail.com","avatar":"https://avatars.githubusercontent.com/u/393160?v=4"},"body":"From: Simon Gerber <gesimu@gmail.com>\n\nCurrently, auto correction doesn't work reliably for commands which must\nrun in a work tree (e.g. `git status`) in Git work trees which are\ncreated from a bare repository.\n\nAs far as I'm able to determine, this has been broken since commit\n659fef199f (help: use early config when autocorrecting aliases,\n2017-06-14), where the call to `git_config()` in `help_unknown_cmd()`\nwas replaced with a call to `read_early_config()`. From what I can tell,\nthe actual cause for the unexpected error is that we call\n`git_default_config()` in the `git_unknown_cmd_config` callback instead\nof simply returning `0` for config entries which we aren't interested\nin.\n\nCalling `git_default_config()` in this callback to `read_early_config()`\nseems like a bad idea since those calls will initialize a bunch of state\nin `environment.c` (among other things `is_bare_repository_cfg`) before\nwe've properly detected that we're running in a work tree.\n\nAll other callbacks provided to `read_early_config()` appear to only\nextract their configurations while simply returning `0` for all other\nconfig keys.\n\nThis commit changes the `git_unknown_cmd_config` callback to not call\n`git_default_config()`. Instead we also simply return `0` for config\nkeys which we're not interested in.\n\nSigned-off-by: Simon Gerber <gesimu@gmail.com>\n---\n help.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/help.c b/help.c\nindex d04542d8261..ae534ff0bae 100644\n--- a/help.c\n+++ b/help.c\n@@ -563,7 +563,7 @@ static int git_unknown_cmd_config(const char *var, const char *value, void *cb)\n \tif (skip_prefix(var, \"alias.\", &p))\n \t\tadd_cmdname(&aliases, p, strlen(p));\n \n-\treturn git_default_config(var, value, cb);\n+\treturn 0;\n }\n \n static int levenshtein_compare(const void *p1, const void *p2)\n-- \ngitgitgadget\n"},{"id":"465951","messageId":"d0a6eea93b58f5a267352690adde00a5b0f3f089.1666970645.git.gitgitgadget@gmail.com","threadId":"58707","inReplyTo":"pull.1373.git.git.1666970645.gitgitgadget@gmail.com","subject":"[PATCH 1/2] tests: add test case for autocorrect in work tree for bare clone","fromName":"Simon Gerber via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-10-28T15:24:04Z","receivedAt":"2022-10-28T15:24:17Z","isPatch":true,"sender":{"key":"gesimu@gmail.com","avatar":"https://avatars.githubusercontent.com/u/393160?v=4"},"body":"From: Simon Gerber <gesimu@gmail.com>\n\nCurrently, auto correction doesn't work reliably for commands which must\nrun in a work tree (e.g. `git status`) in Git work trees which are\ncreated from a bare repository.\n\nThis commit adds a test which shows the broken autocompletion by calling\n`git stauts` which gets autocorrected to `git status`. This works fine\nin a work tree created with `git worktree add` from a regular clone, but\ndoesn't work in a work tree created with `git worktree add` from a bare\nclone.\n\nSigned-off-by: Simon Gerber <gesimu@gmail.com>\n---\n t/t9005-help-autocorrect-worktree.sh | 29 ++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)\n create mode 100755 t/t9005-help-autocorrect-worktree.sh\n\ndiff --git a/t/t9005-help-autocorrect-worktree.sh b/t/t9005-help-autocorrect-worktree.sh\nnew file mode 100755\nindex 00000000000..4fecc8a8e01\n--- /dev/null\n+++ b/t/t9005-help-autocorrect-worktree.sh\n@@ -0,0 +1,29 @@\n+#!/bin/sh\n+\n+test_description='test autocorrect in work tree based on bare repository'\n+. ./test-lib.sh\n+\n+test_expect_success 'setup non-bare' '\n+\techo one >file &&\n+\tgit add file &&\n+\tgit commit -m one &&\n+\techo two >file &&\n+\tgit commit -a -m two\n+'\n+\n+test_expect_success 'setup bare' '\n+\tgit clone --bare . bare.git &&\n+\tcd bare.git\n+'\n+\n+test_expect_success 'setup worktree from bare' '\n+\tgit worktree add ../bare-wt &&\n+\tcd ../bare-wt\n+'\n+\n+test_expect_success 'autocorrect works in work tree created from bare repo' '\n+\tgit config help.autocorrect immediate &&\n+\tgit stauts\n+'\n+\n+test_done\n-- \ngitgitgadget\n\n"},{"id":"465952","messageId":"pull.1373.git.git.1666970645.gitgitgadget@gmail.com","threadId":"58707","inReplyTo":null,"subject":"[PATCH 0/2] Fix autocorrect in work tree for bare repository","fromName":"Simon Gerber via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-10-28T15:24:03Z","receivedAt":"2022-10-28T15:24:19Z","isPatch":true,"sender":{"key":"gesimu@gmail.com","avatar":"https://avatars.githubusercontent.com/u/393160?v=4"},"body":"Currently, auto correction doesn't work reliably for commands which must run\nin a work tree (e.g. git status) in Git work trees which are created from a\nbare repository.\n\nThis patch series adds a test case illustrating the issue and proposes a fix\nwhich adjusts the usage of read_early_config() in help_unknown_cmd() to\nmatch other usages of read_early_config(). In particular the patch removes\nthe call to git_default_config() in the read config callback.\n\nSimon Gerber (2):\n  tests: add test case for autocorrect in work tree for bare clone\n  help.c: don't call git_default_config in git_unknown_cmd_config\n\n help.c                               |  2 +-\n t/t9005-help-autocorrect-worktree.sh | 29 ++++++++++++++++++++++++++++\n 2 files changed, 30 insertions(+), 1 deletion(-)\n create mode 100755 t/t9005-help-autocorrect-worktree.sh\n\n\nbase-commit: e7e5c6f715b2de7bea0d39c7d2ba887335b40aa0\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1373%2Fsimu%2Ffix%2Fautocorrect-bare-worktree-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1373/simu/fix/autocorrect-bare-worktree-v1\nPull-Request: https://github.com/git/git/pull/1373\n-- \ngitgitgadget\n"},{"id":"465968","messageId":"xmqq4jvniw7q.fsf@gitster.g","threadId":"58707","inReplyTo":"d0a6eea93b58f5a267352690adde00a5b0f3f089.1666970645.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/2] tests: add test case for autocorrect in work tree for bare clone","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-10-28T19:28:41Z","receivedAt":"2022-10-28T19:28:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Simon Gerber via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n>  t/t9005-help-autocorrect-worktree.sh | 29 ++++++++++++++++++++++++++++\n\nDon't we have existing test script for auto-correction?  Is it\nsensible to waste a new fail for this single test?  I doubt it.\n\nPerhaps appending after 9003 a new test instead?\n\n> diff --git a/t/t9005-help-autocorrect-worktree.sh b/t/t9005-help-autocorrect-worktree.sh\n> new file mode 100755\n> index 00000000000..4fecc8a8e01\n> --- /dev/null\n> +++ b/t/t9005-help-autocorrect-worktree.sh\n> @@ -0,0 +1,29 @@\n> +#!/bin/sh\n> +\n> +test_description='test autocorrect in work tree based on bare repository'\n> +. ./test-lib.sh\n> +\n> +test_expect_success 'setup non-bare' '\n> +\techo one >file &&\n> +\tgit add file &&\n> +\tgit commit -m one &&\n> +\techo two >file &&\n> +\tgit commit -a -m two\n> +'\n\nWouldn't \"test_commit\" be simpler to use than rolling our own here?\nIf we piggy-back on set-up in an existing test script, there\nprobably is already a history the single test to attempt running\n'git staut' can use.  After all, that test does not care an iota\nwhat is in the history.\n\n> +\n> +test_expect_success 'setup bare' '\n> +\tgit clone --bare . bare.git &&\n> +\tcd bare.git\n\nDo not chdir around in a test script, especially in separate steps.\n\n> +'\n> +\n> +test_expect_success 'setup worktree from bare' '\n> +\tgit worktree add ../bare-wt &&\n> +\tcd ../bare-wt\n> +'\n\nDitto.\n\nEither do it in a subshell in a single step, or\n\n\t(\n\t\tgit clone --bare . bare.git &&\n\t\tcd bare.git &&\n\t\tgit worktree add ../worktree &&\n\t\tcd ../worktree &&\n\t\tgit -c help.autocorrect=immediate staut\n\t)\n\nuse \"git -C <over-there>\" form, e.g.\n\n\tgit clone --bare . bare.git &&\n\tgit -C bare.git worktree add ../worktree &&\n\tgit -C worktree -c help.autocorrect=immediate staut\n\n> +test_expect_success 'autocorrect works in work tree created from bare repo' '\n\nWhen patch 1/2 is applied without 2/2, this test_expect_success will\nnot be satisfied, breaking future bisection.\n\nFor a small change like this, have the code change *and* test that\nverifies the new behaviour in a single step.  That way\n\n * you do not break bisection.\n\n * if somebody wants to cherry-pick the fix to an older maintenance\n   tracks, they can do so by picking a single unit, fix and\n   verification combined together.\n\n * acceptance or review can be done by checking the end-result and\n   then tentatively reverting only the code change with something\n   like\n\n\t$ git show -- ':!t/' | git apply -R\n\n   and see the test that expects success actually fails without the fix.\n"},{"id":"466007","messageId":"CAAyHH32vj14Q9B+diFqGBc4db-C-raxp1F+WZEWdhx66_N+MXA@mail.gmail.com","threadId":"58707","inReplyTo":"xmqq4jvniw7q.fsf@gitster.g","subject":"Re: [PATCH 1/2] tests: add test case for autocorrect in work tree for bare clone","fromName":"Simon Gerber","fromEmail":"gesimu@gmail.com","sentAt":"2022-10-29T08:07:17Z","receivedAt":"2022-10-29T08:07:34Z","isPatch":true,"sender":{"key":"gesimu@gmail.com","avatar":"https://avatars.githubusercontent.com/u/393160?v=4"},"body":"On Fri, 28 Oct 2022 at 21:28, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Simon Gerber via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> >  t/t9005-help-autocorrect-worktree.sh | 29 ++++++++++++++++++++++++++++\n>\n> Don't we have existing test script for auto-correction?  Is it\n> sensible to waste a new fail for this single test?  I doubt it.\n>\n> Perhaps appending after 9003 a new test instead?\n\nI'll move the test to 9003. I was considering doing so in the\nbeginning, but was hesitant to add an only vaguely related test in\n9003 which has the description \"help.autocorrect finding a match\".\n\n>\n> > diff --git a/t/t9005-help-autocorrect-worktree.sh b/t/t9005-help-autocorrect-worktree.sh\n> > new file mode 100755\n> > index 00000000000..4fecc8a8e01\n> > --- /dev/null\n> > +++ b/t/t9005-help-autocorrect-worktree.sh\n> > @@ -0,0 +1,29 @@\n> > +#!/bin/sh\n> > +\n> > +test_description='test autocorrect in work tree based on bare repository'\n> > +. ./test-lib.sh\n> > +\n> > +test_expect_success 'setup non-bare' '\n> > +     echo one >file &&\n> > +     git add file &&\n> > +     git commit -m one &&\n> > +     echo two >file &&\n> > +     git commit -a -m two\n> > +'\n>\n> Wouldn't \"test_commit\" be simpler to use than rolling our own here?\n> If we piggy-back on set-up in an existing test script, there\n> probably is already a history the single test to attempt running\n> 'git staut' can use.  After all, that test does not care an iota\n> what is in the history.\n>\n> > +\n> > +test_expect_success 'setup bare' '\n> > +     git clone --bare . bare.git &&\n> > +     cd bare.git\n>\n> Do not chdir around in a test script, especially in separate steps.\n>\n> > +'\n> > +\n> > +test_expect_success 'setup worktree from bare' '\n> > +     git worktree add ../bare-wt &&\n> > +     cd ../bare-wt\n> > +'\n>\n> Ditto.\n>\n> Either do it in a subshell in a single step, or\n>\n>         (\n>                 git clone --bare . bare.git &&\n>                 cd bare.git &&\n>                 git worktree add ../worktree &&\n>                 cd ../worktree &&\n>                 git -c help.autocorrect=immediate staut\n>         )\n>\n> use \"git -C <over-there>\" form, e.g.\n>\n>         git clone --bare . bare.git &&\n>         git -C bare.git worktree add ../worktree &&\n>         git -C worktree -c help.autocorrect=immediate staut\n>\n\nThanks for taking the time to point out how I'm supposed to use the\ntest framework, I was pretty lost trying to write my test and ended up\ncopying some bits from 7103.\n\n> > +test_expect_success 'autocorrect works in work tree created from bare repo' '\n>\n> When patch 1/2 is applied without 2/2, this test_expect_success will\n> not be satisfied, breaking future bisection.\n>\n> For a small change like this, have the code change *and* test that\n> verifies the new behaviour in a single step.  That way\n>\n>  * you do not break bisection.\n>\n>  * if somebody wants to cherry-pick the fix to an older maintenance\n>    tracks, they can do so by picking a single unit, fix and\n>    verification combined together.\n>\n>  * acceptance or review can be done by checking the end-result and\n>    then tentatively reverting only the code change with something\n>    like\n>\n>         $ git show -- ':!t/' | git apply -R\n>\n>    and see the test that expects success actually fails without the fix.\n\nThat makes sense. I'll resubmit this as a single patch.\n"},{"id":"466036","messageId":"pull.1373.v2.git.git.1667073374852.gitgitgadget@gmail.com","threadId":"58707","inReplyTo":"pull.1373.git.git.1666970645.gitgitgadget@gmail.com","subject":"[PATCH v2] help.c: fix autocorrect in work tree for bare repository","fromName":"Simon Gerber via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-10-29T19:56:14Z","receivedAt":"2022-10-29T19:56:22Z","isPatch":true,"sender":{"key":"gesimu@gmail.com","avatar":"https://avatars.githubusercontent.com/u/393160?v=4"},"body":"From: Simon Gerber <gesimu@gmail.com>\n\nCurrently, auto correction doesn't work reliably for commands which must\nrun in a work tree (e.g. `git status`) in Git work trees which are\ncreated from a bare repository.\n\nAs far as I'm able to determine, this has been broken since commit\n659fef199f (help: use early config when autocorrecting aliases,\n2017-06-14), where the call to `git_config()` in `help_unknown_cmd()`\nwas replaced with a call to `read_early_config()`. From what I can tell,\nthe actual cause for the unexpected error is that we call\n`git_default_config()` in the `git_unknown_cmd_config` callback instead\nof simply returning `0` for config entries which we aren't interested\nin.\n\nCalling `git_default_config()` in this callback to `read_early_config()`\nseems like a bad idea since those calls will initialize a bunch of state\nin `environment.c` (among other things `is_bare_repository_cfg`) before\nwe've properly detected that we're running in a work tree.\n\nAll other callbacks provided to `read_early_config()` appear to only\nextract their configurations while simply returning `0` for all other\nconfig keys.\n\nThis commit changes the `git_unknown_cmd_config` callback to not call\n`git_default_config()`. Instead we also simply return `0` for config\nkeys which we're not interested in.\n\nAdditionally the commit adds a new test case covering `help.autocorrect`\nin a work tree created from a bare clone.\n\nSigned-off-by: Simon Gerber <gesimu@gmail.com>\n---\n    Fix autocorrect in work tree for bare repository\n    \n    Currently, auto correction doesn't work reliably for commands which must\n    run in a work tree (e.g. git status) in Git work trees which are created\n    from a bare repository.\n    \n    This patch adds a test case illustrating the issue and proposes a fix\n    which adjusts the usage of read_early_config() in help_unknown_cmd() to\n    match other usages of read_early_config(). In particular the patch\n    removes the call to git_default_config() in the read config callback.\n    \n    Changes since v1 (both suggested by Junio):\n    \n     * Moved test to 9003\n     * Squashed change and test into a single commit\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1373%2Fsimu%2Ffix%2Fautocorrect-bare-worktree-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1373/simu/fix/autocorrect-bare-worktree-v2\nPull-Request: https://github.com/git/git/pull/1373\n\nRange-diff vs v1:\n\n 1:  d0a6eea93b5 < -:  ----------- tests: add test case for autocorrect in work tree for bare clone\n 2:  7a2bef32439 ! 1:  4c598dbe778 help.c: don't call git_default_config in git_unknown_cmd_config\n     @@ Metadata\n      Author: Simon Gerber <gesimu@gmail.com>\n      \n       ## Commit message ##\n     -    help.c: don't call git_default_config in git_unknown_cmd_config\n     +    help.c: fix autocorrect in work tree for bare repository\n      \n          Currently, auto correction doesn't work reliably for commands which must\n          run in a work tree (e.g. `git status`) in Git work trees which are\n     @@ Commit message\n          `git_default_config()`. Instead we also simply return `0` for config\n          keys which we're not interested in.\n      \n     +    Additionally the commit adds a new test case covering `help.autocorrect`\n     +    in a work tree created from a bare clone.\n     +\n          Signed-off-by: Simon Gerber <gesimu@gmail.com>\n      \n       ## help.c ##\n     @@ help.c: static int git_unknown_cmd_config(const char *var, const char *value, vo\n       }\n       \n       static int levenshtein_compare(const void *p1, const void *p2)\n     +\n     + ## t/t9003-help-autocorrect.sh ##\n     +@@ t/t9003-help-autocorrect.sh: test_expect_success 'autocorrect can be declined altogether' '\n     + \ttest_line_count = 1 actual\n     + '\n     + \n     ++test_expect_success 'autocorrect works in work tree created from bare repo' '\n     ++\tgit clone --bare . bare.git &&\n     ++\tgit -C bare.git worktree add ../worktree &&\n     ++\tgit -C worktree -c help.autocorrect=immediate stauts\n     ++'\n     ++\n     + test_done\n\n\n help.c                      | 2 +-\n t/t9003-help-autocorrect.sh | 6 ++++++\n 2 files changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/help.c b/help.c\nindex d04542d8261..ae534ff0bae 100644\n--- a/help.c\n+++ b/help.c\n@@ -563,7 +563,7 @@ static int git_unknown_cmd_config(const char *var, const char *value, void *cb)\n \tif (skip_prefix(var, \"alias.\", &p))\n \t\tadd_cmdname(&aliases, p, strlen(p));\n \n-\treturn git_default_config(var, value, cb);\n+\treturn 0;\n }\n \n static int levenshtein_compare(const void *p1, const void *p2)\ndiff --git a/t/t9003-help-autocorrect.sh b/t/t9003-help-autocorrect.sh\nindex f00deaf3815..f5b6b4f746b 100755\n--- a/t/t9003-help-autocorrect.sh\n+++ b/t/t9003-help-autocorrect.sh\n@@ -60,4 +60,10 @@ test_expect_success 'autocorrect can be declined altogether' '\n \ttest_line_count = 1 actual\n '\n \n+test_expect_success 'autocorrect works in work tree created from bare repo' '\n+\tgit clone --bare . bare.git &&\n+\tgit -C bare.git worktree add ../worktree &&\n+\tgit -C worktree -c help.autocorrect=immediate stauts\n+'\n+\n test_done\n\nbase-commit: e7e5c6f715b2de7bea0d39c7d2ba887335b40aa0\n-- \ngitgitgadget\n"},{"id":"468904","messageId":"CAAyHH30eoRAgtO+QOZZFbx89Nr55xtndu6pRa5k=ZnJZXnZACw@mail.gmail.com","threadId":"58707","inReplyTo":"pull.1373.v2.git.git.1667073374852.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] help.c: fix autocorrect in work tree for bare repository","fromName":"Simon Gerber","fromEmail":"gesimu@gmail.com","sentAt":"2022-12-12T16:38:54Z","receivedAt":"2022-12-12T16:42:17Z","isPatch":true,"sender":{"key":"gesimu@gmail.com","avatar":"https://avatars.githubusercontent.com/u/393160?v=4"},"body":"On Sat, 29 Oct 2022 at 21:56, Simon Gerber via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> [commit message omitted]\n> ---\n>     Fix autocorrect in work tree for bare repository\n>\n>     Currently, auto correction doesn't work reliably for commands which must\n>     run in a work tree (e.g. git status) in Git work trees which are created\n>     from a bare repository.\n>\n>     This patch adds a test case illustrating the issue and proposes a fix\n>     which adjusts the usage of read_early_config() in help_unknown_cmd() to\n>     match other usages of read_early_config(). In particular the patch\n>     removes the call to git_default_config() in the read config callback.\n>\n>     Changes since v1 (both suggested by Junio):\n>\n>      * Moved test to 9003\n>      * Squashed change and test into a single commit\n>\n> [diff omitted]\n\nHi all,\n\nJust wanted to check what the state on this patch is (side-note: I\njust noticed that I didn't cc Junio in the v2 submission, my\napologies). As described in the quote (and the parent email), the\npatch fixes how auto correct initializes the config. Version 2\naddresses the points raised on v1, in particular, I've moved the test\nto 9003, and have squashed the change into a single commit. Please let\nme know if further changes are necessary.\n\n-- Simon\n"},{"id":"468968","messageId":"xmqqa63sqe1b.fsf@gitster.g","threadId":"58707","inReplyTo":"pull.1373.v2.git.git.1667073374852.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] help.c: fix autocorrect in work tree for bare repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-12-13T01:37:52Z","receivedAt":"2022-12-13T01:38:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Simon Gerber via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Calling `git_default_config()` in this callback to `read_early_config()`\n> seems like a bad idea since those calls will initialize a bunch of state\n> in `environment.c` (among other things `is_bare_repository_cfg`) before\n> we've properly detected that we're running in a work tree.\n>\n> All other callbacks provided to `read_early_config()` appear to only\n> extract their configurations while simply returning `0` for all other\n> config keys.\n\nVery good observation and justification for this change.\n\n>  help.c                      | 2 +-\n>  t/t9003-help-autocorrect.sh | 6 ++++++\n>  2 files changed, 7 insertions(+), 1 deletion(-)\n>\n> diff --git a/help.c b/help.c\n> index d04542d8261..ae534ff0bae 100644\n> --- a/help.c\n> +++ b/help.c\n> @@ -563,7 +563,7 @@ static int git_unknown_cmd_config(const char *var, const char *value, void *cb)\n>  \tif (skip_prefix(var, \"alias.\", &p))\n>  \t\tadd_cmdname(&aliases, p, strlen(p));\n>  \n> -\treturn git_default_config(var, value, cb);\n> +\treturn 0;\n>  }\n\nAnd this is exactly what the proposed log message promises to do.\n\n>  static int levenshtein_compare(const void *p1, const void *p2)\n> diff --git a/t/t9003-help-autocorrect.sh b/t/t9003-help-autocorrect.sh\n> index f00deaf3815..f5b6b4f746b 100755\n> --- a/t/t9003-help-autocorrect.sh\n> +++ b/t/t9003-help-autocorrect.sh\n> @@ -60,4 +60,10 @@ test_expect_success 'autocorrect can be declined altogether' '\n>  \ttest_line_count = 1 actual\n>  '\n>  \n> +test_expect_success 'autocorrect works in work tree created from bare repo' '\n> +\tgit clone --bare . bare.git &&\n> +\tgit -C bare.git worktree add ../worktree &&\n> +\tgit -C worktree -c help.autocorrect=immediate stauts\n\nThe reason why this third line is a sufficient test is...?\n\nIf \"status\" is invoked successfully, it would not exit with non-zero\nstatus as long as it correctly notices that it was invoked in a\nworktree (as opposed to the current code without your fix, which\nwould say \"nah, where you are running there is no worktree\", that is\nincorrect), but one scenario I am a bit worried about is what if the\ntester has an entry on $PATH that has \"git-static\" or whatever that\nis similar enough to \"status\", to cause autocorrect work differently\nfrom the case where \"git status\" would be the only plausible case.\n\nBut then we can tell such a tester \"don't do that, then\" ;-)\n\nLet's queue the patch as-is and see what others think.\n\nThanks.\n\n> +'\n> +\n>  test_done\n\n"},{"id":"468974","messageId":"CAAyHH3239rmRR5mhy-cS7XFVuXi2AnYG5nQkFcpKMd4WTfmoBg@mail.gmail.com","threadId":"58707","inReplyTo":"xmqqa63sqe1b.fsf@gitster.g","subject":"Re: [PATCH v2] help.c: fix autocorrect in work tree for bare repository","fromName":"Simon Gerber","fromEmail":"gesimu@gmail.com","sentAt":"2022-12-13T09:48:23Z","receivedAt":"2022-12-13T09:48:50Z","isPatch":true,"sender":{"key":"gesimu@gmail.com","avatar":"https://avatars.githubusercontent.com/u/393160?v=4"},"body":"On Tue, 13 Dec 2022 at 02:37, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Simon Gerber via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > --- a/t/t9003-help-autocorrect.sh\n> > +++ b/t/t9003-help-autocorrect.sh\n> > @@ -60,4 +60,10 @@ test_expect_success 'autocorrect can be declined altogether' '\n> >       test_line_count = 1 actual\n> >  '\n> >\n> > +test_expect_success 'autocorrect works in work tree created from bare repo' '\n> > +     git clone --bare . bare.git &&\n> > +     git -C bare.git worktree add ../worktree &&\n> > +     git -C worktree -c help.autocorrect=immediate stauts\n>\n> The reason why this third line is a sufficient test is...?\n>\n> If \"status\" is invoked successfully, it would not exit with non-zero\n> status as long as it correctly notices that it was invoked in a\n> worktree (as opposed to the current code without your fix, which\n> would say \"nah, where you are running there is no worktree\", that is\n> incorrect), but one scenario I am a bit worried about is what if the\n> tester has an entry on $PATH that has \"git-static\" or whatever that\n> is similar enough to \"status\", to cause autocorrect work differently\n> from the case where \"git status\" would be the only plausible case.\n\nThanks for pointing out that autocorrect could work differently for a\ntester depending on what's in their path. I didn't consider that case\nat all.\n\n>\n> But then we can tell such a tester \"don't do that, then\" ;-)\n\nI think that's fine in this case.\n\n>\n> Let's queue the patch as-is and see what others think.\n\nAwesome, thanks\n\n>\n> Thanks.\n>\n> > +'\n> > +\n> >  test_done\n>\n"}]}