{"thread":{"id":"57788","subject":"[PATCH] submodule--helper: fix initialization of warn_if_uninitialized","startedAt":"2022-04-24T06:26:26Z","lastAt":"2022-04-27T23:21:00Z","messageCount":11,"participants":["Orgad Shaneh via GitGitGadget","Junio C Hamano","Orgad Shaneh","Glen Choo"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"454353","messageId":"pull.1258.git.git.1650781575173.gitgitgadget@gmail.com","threadId":"57788","inReplyTo":null,"subject":"[PATCH] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Orgad Shaneh via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-04-24T06:26:15Z","receivedAt":"2022-04-24T06:26:26Z","isPatch":true,"sender":{"key":"orgads@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1246544?v=4"},"body":"From: Orgad Shaneh <orgads@gmail.com>\n\nThis field is supposed to be off by default, and it is only enabled when\nrunning `git submodule update <path>`, and path is not initialized.\n\nCommit c9911c9358 changed it to enabled by default. This affects for\nexample git checkout, which displays the following warning for each\nuninitialized submodule:\n\nSubmodule path 'sub' not initialized\nMaybe you want to use 'update --init'?\n\nAmends c9911c9358e611390e2444f718c73900d17d3d60.\n\nSigned-off-by: Orgad Shaneh <orgads@gmail.com>\n---\n    submodule--helper: fix initialization of warn_if_uninitialized\n    \n    This field is supposed to be off by default, and it is only enabled when\n    running git submodule update <path>, and path is not initialized.\n    \n    Commit c9911c9358 changed it to enabled by default. This affects for\n    example git checkout, which displays the following warning for each\n    uninitialized submodule:\n    \n    Submodule path 'sub' not initialized\n    Maybe you want to use 'update --init'?\n    \n    \n    Amends c9911c9358e611390e2444f718c73900d17d3d60.\n    \n    Signed-off-by: Orgad Shaneh orgads@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v1\nPull-Request: https://github.com/git/git/pull/1258\n\n builtin/submodule--helper.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 2c87ef9364f..b28112e3040 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2026,7 +2026,7 @@ struct update_data {\n \t.references = STRING_LIST_INIT_DUP, \\\n \t.single_branch = -1, \\\n \t.max_jobs = 1, \\\n-\t.warn_if_uninitialized = 1, \\\n+\t.warn_if_uninitialized = 0, \\\n }\n \n static void next_submodule_warn_missing(struct submodule_update_clone *suc,\n\nbase-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e\n-- \ngitgitgadget\n"},{"id":"454374","messageId":"xmqqee1ly0ab.fsf@gitster.g","threadId":"57788","inReplyTo":"pull.1258.git.git.1650781575173.gitgitgadget@gmail.com","subject":"Re: [PATCH] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-04-25T09:34:04Z","receivedAt":"2022-04-25T09:36:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Orgad Shaneh via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Orgad Shaneh <orgads@gmail.com>\n>\n> This field is supposed to be off by default, and it is only enabled when\n> running `git submodule update <path>`, and path is not initialized.\n\n\"is supposed to be\": can you substantiate it with evidence and\nlogic?\n\nOne easy way to explain the above is to examine what the default\nvalue was before the problematic commit, and go back from that\ncommit to see how the default was decided, and examine how the\nmember is used.\n\n> Commit c9911c9358 changed it to enabled by default. This affects\n> for example git checkout, which displays the following warning for\n> each uninitialized submodule:\n>\n> Submodule path 'sub' not initialized\n> Maybe you want to use 'update --init'?\n\nWe refer to an existing commit like this:\n\n    c9911c93 (submodule--helper: teach update_data more options,\n    2022-03-15) changed it to be enabled by default.\n\nSo, taking the above together:\n\n    The .warn_if_uninitialized member was introduced by 48308681\n    (git submodule update: have a dedicated helper for cloning,\n    2016-02-29) to submodule_update_clone struct and initialized to\n    false.  When c9911c93 (submodule--helper: teach update_data more\n    options, 2022-03-15) moved it to update_data struct, it started\n    to initialize it to true but this change was not explained in\n    its log message.\n\n    The member is set to true only when pathspec was given, and is\n    used when a submodule that matched the pathspec is found\n    uninitialized to give diagnostic message.  \"submodule update\"\n    without pathspec is supposed to iterate over all submodules\n    (i.e. without pathspec limitation) and update only the\n    initialized submodules, and finding uninitialized submodules\n    during the iteration is a totally expected and normal thing that\n    should not be warned.\n\n    Fix this regression by initializing the member to 0.\n\n> Amends c9911c9358e611390e2444f718c73900d17d3d60.\n\nIn the context of \"git\", the verb \"amend\" has a specific meaning\n(i.e. \"commit --amend\"), and we should refrain from using it when we\nare doing something else to avoid confusing readers.\n\nWe could say\n\n    Fix this problem that was introduced by c9911c93\n    (submodule--helper: teach update_data more options, 2022-03-15)\n\nbut it is not necessary, as long as we explained how that commit\nbroke the code to justify this change (which we should do anyway).\n\n>\n> Signed-off-by: Orgad Shaneh <orgads@gmail.com>\n> ---\n>     submodule--helper: fix initialization of warn_if_uninitialized\n> ...\n>     Signed-off-by: Orgad Shaneh orgads@gmail.com\n\nHere under three-dash line is where you would write comment meant\nfor those who read the message on the list that are not necessarily\nmeant to be part of resulting commit.  Repeating the same message as\nthe log message is not desired here.\n\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v1\n> Pull-Request: https://github.com/git/git/pull/1258\n>\n>  builtin/submodule--helper.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index 2c87ef9364f..b28112e3040 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -2026,7 +2026,7 @@ struct update_data {\n>  \t.references = STRING_LIST_INIT_DUP, \\\n>  \t.single_branch = -1, \\\n>  \t.max_jobs = 1, \\\n> -\t.warn_if_uninitialized = 1, \\\n> +\t.warn_if_uninitialized = 0, \\\n>  }\n\nThis is not wrong per-se, but omitting the mention of the member\naltogether and letting the compiler initialize it to 0 would\nprobably be a better fix.\n\nThanks.\n"},{"id":"454380","messageId":"CAGHpTB+K3TP64xBknU9GrH7WAxOLSk76buiGGpNMYA0ryEm=5A@mail.gmail.com","threadId":"57788","inReplyTo":"xmqqee1ly0ab.fsf@gitster.g","subject":"Re: [PATCH] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Orgad Shaneh","fromEmail":"orgads@gmail.com","sentAt":"2022-04-25T12:43:21Z","receivedAt":"2022-04-25T12:44:55Z","isPatch":true,"sender":{"key":"orgads@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1246544?v=4"},"body":"On Mon, Apr 25, 2022 at 12:34 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Orgad Shaneh via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Orgad Shaneh <orgads@gmail.com>\n> >\n> > This field is supposed to be off by default, and it is only enabled when\n> > running `git submodule update <path>`, and path is not initialized.\n>\n> \"is supposed to be\": can you substantiate it with evidence and\n> logic?\n>\n> One easy way to explain the above is to examine what the default\n> value was before the problematic commit, and go back from that\n> commit to see how the default was decided, and examine how the\n> member is used.\n>\n> > Commit c9911c9358 changed it to enabled by default. This affects\n> > for example git checkout, which displays the following warning for\n> > each uninitialized submodule:\n> >\n> > Submodule path 'sub' not initialized\n> > Maybe you want to use 'update --init'?\n>\n> We refer to an existing commit like this:\n>\n>     c9911c93 (submodule--helper: teach update_data more options,\n>     2022-03-15) changed it to be enabled by default.\n>\n> So, taking the above together:\n>\n>     The .warn_if_uninitialized member was introduced by 48308681\n>     (git submodule update: have a dedicated helper for cloning,\n>     2016-02-29) to submodule_update_clone struct and initialized to\n>     false.  When c9911c93 (submodule--helper: teach update_data more\n>     options, 2022-03-15) moved it to update_data struct, it started\n>     to initialize it to true but this change was not explained in\n>     its log message.\n>\n>     The member is set to true only when pathspec was given, and is\n>     used when a submodule that matched the pathspec is found\n>     uninitialized to give diagnostic message.  \"submodule update\"\n>     without pathspec is supposed to iterate over all submodules\n>     (i.e. without pathspec limitation) and update only the\n>     initialized submodules, and finding uninitialized submodules\n>     during the iteration is a totally expected and normal thing that\n>     should not be warned.\n>\n>     Fix this regression by initializing the member to 0.\n\nThank you very much. Updated.\n\n> > Amends c9911c9358e611390e2444f718c73900d17d3d60.\n>\n> In the context of \"git\", the verb \"amend\" has a specific meaning\n> (i.e. \"commit --amend\"), and we should refrain from using it when we\n> are doing something else to avoid confusing readers.\n>\n> We could say\n>\n>     Fix this problem that was introduced by c9911c93\n>     (submodule--helper: teach update_data more options, 2022-03-15)\n>\n> but it is not necessary, as long as we explained how that commit\n> broke the code to justify this change (which we should do anyway).\n\nI'm used to this from other projects, but ok.\n\n> > ---\n> >     submodule--helper: fix initialization of warn_if_uninitialized\n> > ...\n> >     Signed-off-by: Orgad Shaneh orgads@gmail.com\n>\n> Here under three-dash line is where you would write comment meant\n> for those who read the message on the list that are not necessarily\n> meant to be part of resulting commit.  Repeating the same message as\n> the log message is not desired here.\n\nThis was done by GitGitGadget. I have no idea how to avoid it.\n\n> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v1\n> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v1\n> > Pull-Request: https://github.com/git/git/pull/1258\n> >\n> >  builtin/submodule--helper.c | 2 +-\n> >  1 file changed, 1 insertion(+), 1 deletion(-)\n> >\n> > diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> > index 2c87ef9364f..b28112e3040 100644\n> > --- a/builtin/submodule--helper.c\n> > +++ b/builtin/submodule--helper.c\n> > @@ -2026,7 +2026,7 @@ struct update_data {\n> >       .references = STRING_LIST_INIT_DUP, \\\n> >       .single_branch = -1, \\\n> >       .max_jobs = 1, \\\n> > -     .warn_if_uninitialized = 1, \\\n> > +     .warn_if_uninitialized = 0, \\\n> >  }\n>\n> This is not wrong per-se, but omitting the mention of the member\n> altogether and letting the compiler initialize it to 0 would\n> probably be a better fix.\n\nDone.\n\nThanks for the review.\n\n- Orgad\n"},{"id":"454381","messageId":"pull.1258.v2.git.git.1650890741430.gitgitgadget@gmail.com","threadId":"57788","inReplyTo":"pull.1258.git.git.1650781575173.gitgitgadget@gmail.com","subject":"[PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Orgad Shaneh via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-04-25T12:45:41Z","receivedAt":"2022-04-25T12:46:37Z","isPatch":true,"sender":{"key":"orgads@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1246544?v=4"},"body":"From: Orgad Shaneh <orgads@gmail.com>\n\nThe .warn_if_uninitialized member was introduced by 48308681\n(git submodule update: have a dedicated helper for cloning,\n2016-02-29) to submodule_update_clone struct and initialized to\nfalse.  When c9911c93 (submodule--helper: teach update_data more\noptions, 2022-03-15) moved it to update_data struct, it started\nto initialize it to true but this change was not explained in\nits log message.\n\nThe member is set to true only when pathspec was given, and is\nused when a submodule that matched the pathspec is found\nuninitialized to give diagnostic message.  \"submodule update\"\nwithout pathspec is supposed to iterate over all submodules\n(i.e. without pathspec limitation) and update only the\ninitialized submodules, and finding uninitialized submodules\nduring the iteration is a totally expected and normal thing that\nshould not be warned.\n\nSigned-off-by: Orgad Shaneh <orgads@gmail.com>\n---\n    submodule--helper: fix initialization of warn_if_uninitialized\n    \n    The .warn_if_uninitialized member was introduced by 48308681 (git\n    submodule update: have a dedicated helper for cloning, 2016-02-29) to\n    submodule_update_clone struct and initialized to false. When c9911c93\n    (submodule--helper: teach update_data more options, 2022-03-15) moved it\n    to update_data struct, it started to initialize it to true but this\n    change was not explained in its log message.\n    \n    The member is set to true only when pathspec was given, and is used when\n    a submodule that matched the pathspec is found uninitialized to give\n    diagnostic message. \"submodule update\" without pathspec is supposed to\n    iterate over all submodules (i.e. without pathspec limitation) and\n    update only the initialized submodules, and finding uninitialized\n    submodules during the iteration is a totally expected and normal thing\n    that should not be warned.\n    \n    Signed-off-by: Orgad Shaneh orgads@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v2\nPull-Request: https://github.com/git/git/pull/1258\n\nRange-diff vs v1:\n\n 1:  089a52a50b4 ! 1:  1e34c9cad18 submodule--helper: fix initialization of warn_if_uninitialized\n     @@ Metadata\n       ## Commit message ##\n          submodule--helper: fix initialization of warn_if_uninitialized\n      \n     -    This field is supposed to be off by default, and it is only enabled when\n     -    running `git submodule update <path>`, and path is not initialized.\n     +    The .warn_if_uninitialized member was introduced by 48308681\n     +    (git submodule update: have a dedicated helper for cloning,\n     +    2016-02-29) to submodule_update_clone struct and initialized to\n     +    false.  When c9911c93 (submodule--helper: teach update_data more\n     +    options, 2022-03-15) moved it to update_data struct, it started\n     +    to initialize it to true but this change was not explained in\n     +    its log message.\n      \n     -    Commit c9911c9358 changed it to enabled by default. This affects for\n     -    example git checkout, which displays the following warning for each\n     -    uninitialized submodule:\n     -\n     -    Submodule path 'sub' not initialized\n     -    Maybe you want to use 'update --init'?\n     -\n     -    Amends c9911c9358e611390e2444f718c73900d17d3d60.\n     +    The member is set to true only when pathspec was given, and is\n     +    used when a submodule that matched the pathspec is found\n     +    uninitialized to give diagnostic message.  \"submodule update\"\n     +    without pathspec is supposed to iterate over all submodules\n     +    (i.e. without pathspec limitation) and update only the\n     +    initialized submodules, and finding uninitialized submodules\n     +    during the iteration is a totally expected and normal thing that\n     +    should not be warned.\n      \n          Signed-off-by: Orgad Shaneh <orgads@gmail.com>\n      \n     @@ builtin/submodule--helper.c: struct update_data {\n       \t.single_branch = -1, \\\n       \t.max_jobs = 1, \\\n      -\t.warn_if_uninitialized = 1, \\\n     -+\t.warn_if_uninitialized = 0, \\\n       }\n       \n       static void next_submodule_warn_missing(struct submodule_update_clone *suc,\n\n\n builtin/submodule--helper.c | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 2c87ef9364f..1a8e5d06214 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2026,7 +2026,6 @@ struct update_data {\n \t.references = STRING_LIST_INIT_DUP, \\\n \t.single_branch = -1, \\\n \t.max_jobs = 1, \\\n-\t.warn_if_uninitialized = 1, \\\n }\n \n static void next_submodule_warn_missing(struct submodule_update_clone *suc,\n\nbase-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e\n-- \ngitgitgadget\n"},{"id":"454399","messageId":"xmqq35i1vx3y.fsf@gitster.g","threadId":"57788","inReplyTo":"pull.1258.v2.git.git.1650890741430.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-04-25T18:25:37Z","receivedAt":"2022-04-25T18:25:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Orgad Shaneh via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> The member is set to true only when pathspec was given, and is\n> used when a submodule that matched the pathspec is found\n> uninitialized to give diagnostic message.  \"submodule update\"\n> without pathspec is supposed to iterate over all submodules\n> (i.e. without pathspec limitation) and update only the\n> initialized submodules, and finding uninitialized submodules\n> during the iteration is a totally expected and normal thing that\n> should not be warned.\n> ...\n>  builtin/submodule--helper.c | 1 -\n>  1 file changed, 1 deletion(-)\n>\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index 2c87ef9364f..1a8e5d06214 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -2026,7 +2026,6 @@ struct update_data {\n>  \t.references = STRING_LIST_INIT_DUP, \\\n>  \t.single_branch = -1, \\\n>  \t.max_jobs = 1, \\\n> -\t.warn_if_uninitialized = 1, \\\n>  }\n\nIs this a fix we can protect from future breakge by adding a test or\ntweaking an existing test?  It is kind of surprising if we did not\nhave any test that runs \"git submodule update\" in a superproject\nwith initialized and uninitialized submodule(s) and make sure only\nthe initialized ones are updated.  It may be the matter of examining\nthe warning output that is currently ignored in such a test, if\nthere is one.\n\nThanks.\n\n\n"},{"id":"454409","messageId":"xmqqtuagvq4n.fsf@gitster.g","threadId":"57788","inReplyTo":"xmqq35i1vx3y.fsf@gitster.g","subject":"Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-04-25T20:56:24Z","receivedAt":"2022-04-25T20:56:32Z","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> Is this a fix we can protect from future breakge by adding a test or\n> tweaking an existing test?  It is kind of surprising if we did not\n> have any test that runs \"git submodule update\" in a superproject\n> with initialized and uninitialized submodule(s) and make sure only\n> the initialized ones are updated.  It may be the matter of examining\n> the warning output that is currently ignored in such a test, if\n> there is one.\n\nHere is a quick-and-dirty one I came up with.  The superproject\n\"super\" has a handful of submodules (\"submodule\" and \"rebasing\"\nbeing two of them), so the new tests clone the superproject and\ninitializes only one submodule.  Then we see how \"submodule update\"\nwith pathspec works with these two submodules (one initialied and\nthe other not).  In another test, we see how \"submodule update\"\nwithout pathspec works.\n\nI'll queue this on top of your fix for now tentatively.  If nobody\nfinds flaws in them, I'll just squash it in soonish before merging\nthe whole thing for the maintenance track.\n\nThanks.\n\n t/t7406-submodule-update.sh | 33 +++++++++++++++++++++++++++++++++\n 1 file changed, 33 insertions(+)\n\ndiff --git c/t/t7406-submodule-update.sh w/t/t7406-submodule-update.sh\nindex 000e055811..43f779d751 100755\n--- c/t/t7406-submodule-update.sh\n+++ w/t/t7406-submodule-update.sh\n@@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '\n \t)\n '\n \n+test_expect_success 'submodule update with pathspec warns against uninitialized ones' '\n+\ttest_when_finished \"rm -fr selective\" &&\n+\tgit clone super selective &&\n+\t(\n+\t\tcd selective &&\n+\t\tgit submodule init submodule &&\n+\n+\t\tgit submodule update submodule 2>err &&\n+\t\t! grep \"Submodule path .* not initialized\" err &&\n+\n+\t\tgit submodule update rebasing 2>err &&\n+\t\tgrep \"Submodule path .rebasing. not initialized\" err &&\n+\n+\t\ttest_path_exists submodule/.git &&\n+\t\ttest_path_is_missing rebasing/.git\n+\t)\n+\n+'\n+\n+test_expect_success 'submodule update without pathspec updates only initialized ones' '\n+\ttest_when_finished \"rm -fr selective\" &&\n+\tgit clone super selective &&\n+\t(\n+\t\tcd selective &&\n+\t\tgit submodule init submodule &&\n+\t\tgit submodule update 2>err &&\n+\t\ttest_path_exists submodule/.git &&\n+\t\ttest_path_is_missing rebasing/.git &&\n+\t\t! grep \"Submodule path .* not initialized\" err\n+\t)\n+\n+'\n+\n test_expect_success 'submodule update continues after checkout error' '\n \t(cd super &&\n \t git reset --hard HEAD &&\n"},{"id":"454556","messageId":"kl6lczh2p3nv.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57788","inReplyTo":"xmqqtuagvq4n.fsf@gitster.g","subject":"Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-04-27T22:22:44Z","receivedAt":"2022-04-27T22:22:50Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Is this a fix we can protect from future breakge by adding a test or\n>> tweaking an existing test?  It is kind of surprising if we did not\n>> have any test that runs \"git submodule update\" in a superproject\n>> with initialized and uninitialized submodule(s) and make sure only\n>> the initialized ones are updated.  It may be the matter of examining\n>> the warning output that is currently ignored in such a test, if\n>> there is one.\n>\n> Here is a quick-and-dirty one I came up with.  The superproject\n> \"super\" has a handful of submodules (\"submodule\" and \"rebasing\"\n> being two of them), so the new tests clone the superproject and\n> initializes only one submodule.  Then we see how \"submodule update\"\n> with pathspec works with these two submodules (one initialied and\n> the other not).  In another test, we see how \"submodule update\"\n> without pathspec works.\n>\n> I'll queue this on top of your fix for now tentatively.  If nobody\n> finds flaws in them, I'll just squash it in soonish before merging\n> the whole thing for the maintenance track.\n>\n> Thanks.\n\nThanks for adding the tests!\n\n>  t/t7406-submodule-update.sh | 33 +++++++++++++++++++++++++++++++++\n>  1 file changed, 33 insertions(+)\n>\n> diff --git c/t/t7406-submodule-update.sh w/t/t7406-submodule-update.sh\n> index 000e055811..43f779d751 100755\n> --- c/t/t7406-submodule-update.sh\n> +++ w/t/t7406-submodule-update.sh\n> @@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '\n>  \t)\n>  '\n>  \n> +test_expect_success 'submodule update with pathspec warns against uninitialized ones' '\n> +\ttest_when_finished \"rm -fr selective\" &&\n> +\tgit clone super selective &&\n> +\t(\n> +\t\tcd selective &&\n> +\t\tgit submodule init submodule &&\n> +\n> +\t\tgit submodule update submodule 2>err &&\n> +\t\t! grep \"Submodule path .* not initialized\" err &&\n> +\n> +\t\tgit submodule update rebasing 2>err &&\n> +\t\tgrep \"Submodule path .rebasing. not initialized\" err &&\n> +\n> +\t\ttest_path_exists submodule/.git &&\n> +\t\ttest_path_is_missing rebasing/.git\n> +\t)\n> +\n> +'\n> +\n> +test_expect_success 'submodule update without pathspec updates only initialized ones' '\n> +\ttest_when_finished \"rm -fr selective\" &&\n> +\tgit clone super selective &&\n> +\t(\n> +\t\tcd selective &&\n> +\t\tgit submodule init submodule &&\n> +\t\tgit submodule update 2>err &&\n> +\t\ttest_path_exists submodule/.git &&\n> +\t\ttest_path_is_missing rebasing/.git &&\n> +\t\t! grep \"Submodule path .* not initialized\" err\n> +\t)\n> +\n> +'\n> +\n>  test_expect_success 'submodule update continues after checkout error' '\n>  \t(cd super &&\n>  \t git reset --hard HEAD &&\n\nSo we test that we only issue the warning when a pathspec is given, and\nthat we ignore uninitialized submodules when no pathspec is given. I\nthink this covers all of the cases, so this looks good, thanks!\n"},{"id":"454557","messageId":"kl6lbkwmp3ne.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57788","inReplyTo":"xmqqtuagvq4n.fsf@gitster.g","subject":"Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-04-27T22:23:01Z","receivedAt":"2022-04-27T22:23:07Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Is this a fix we can protect from future breakge by adding a test or\n>> tweaking an existing test?  It is kind of surprising if we did not\n>> have any test that runs \"git submodule update\" in a superproject\n>> with initialized and uninitialized submodule(s) and make sure only\n>> the initialized ones are updated.  It may be the matter of examining\n>> the warning output that is currently ignored in such a test, if\n>> there is one.\n>\n> Here is a quick-and-dirty one I came up with.  The superproject\n> \"super\" has a handful of submodules (\"submodule\" and \"rebasing\"\n> being two of them), so the new tests clone the superproject and\n> initializes only one submodule.  Then we see how \"submodule update\"\n> with pathspec works with these two submodules (one initialied and\n> the other not).  In another test, we see how \"submodule update\"\n> without pathspec works.\n>\n> I'll queue this on top of your fix for now tentatively.  If nobody\n> finds flaws in them, I'll just squash it in soonish before merging\n> the whole thing for the maintenance track.\n>\n> Thanks.\n\nThanks for adding the tests!\n\n>  t/t7406-submodule-update.sh | 33 +++++++++++++++++++++++++++++++++\n>  1 file changed, 33 insertions(+)\n>\n> diff --git c/t/t7406-submodule-update.sh w/t/t7406-submodule-update.sh\n> index 000e055811..43f779d751 100755\n> --- c/t/t7406-submodule-update.sh\n> +++ w/t/t7406-submodule-update.sh\n> @@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '\n>  \t)\n>  '\n>  \n> +test_expect_success 'submodule update with pathspec warns against uninitialized ones' '\n> +\ttest_when_finished \"rm -fr selective\" &&\n> +\tgit clone super selective &&\n> +\t(\n> +\t\tcd selective &&\n> +\t\tgit submodule init submodule &&\n> +\n> +\t\tgit submodule update submodule 2>err &&\n> +\t\t! grep \"Submodule path .* not initialized\" err &&\n> +\n> +\t\tgit submodule update rebasing 2>err &&\n> +\t\tgrep \"Submodule path .rebasing. not initialized\" err &&\n> +\n> +\t\ttest_path_exists submodule/.git &&\n> +\t\ttest_path_is_missing rebasing/.git\n> +\t)\n> +\n> +'\n> +\n> +test_expect_success 'submodule update without pathspec updates only initialized ones' '\n> +\ttest_when_finished \"rm -fr selective\" &&\n> +\tgit clone super selective &&\n> +\t(\n> +\t\tcd selective &&\n> +\t\tgit submodule init submodule &&\n> +\t\tgit submodule update 2>err &&\n> +\t\ttest_path_exists submodule/.git &&\n> +\t\ttest_path_is_missing rebasing/.git &&\n> +\t\t! grep \"Submodule path .* not initialized\" err\n> +\t)\n> +\n> +'\n> +\n>  test_expect_success 'submodule update continues after checkout error' '\n>  \t(cd super &&\n>  \t git reset --hard HEAD &&\n\nSo we test that we only issue the warning when a pathspec is given, and\nthat we ignore uninitialized submodules when no pathspec is given. I\nthink this covers all of the cases, so this looks good, thanks!\n"},{"id":"454558","messageId":"kl6lfslyp3ti.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57788","inReplyTo":"pull.1258.v2.git.git.1650890741430.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-04-27T22:19:21Z","receivedAt":"2022-04-27T22:25:09Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"\"Orgad Shaneh via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Orgad Shaneh <orgads@gmail.com>\n>\n> The .warn_if_uninitialized member was introduced by 48308681\n> (git submodule update: have a dedicated helper for cloning,\n> 2016-02-29) to submodule_update_clone struct and initialized to\n> false.  When c9911c93 (submodule--helper: teach update_data more\n> options, 2022-03-15) moved it to update_data struct, it started\n> to initialize it to true but this change was not explained in\n> its log message.\n>\n> The member is set to true only when pathspec was given, and is\n> used when a submodule that matched the pathspec is found\n> uninitialized to give diagnostic message.  \"submodule update\"\n> without pathspec is supposed to iterate over all submodules\n> (i.e. without pathspec limitation) and update only the\n> initialized submodules, and finding uninitialized submodules\n> during the iteration is a totally expected and normal thing that\n> should not be warned.\n>\n> Signed-off-by: Orgad Shaneh <orgads@gmail.com>\n> ---\n>     submodule--helper: fix initialization of warn_if_uninitialized\n>     \n>     The .warn_if_uninitialized member was introduced by 48308681 (git\n>     submodule update: have a dedicated helper for cloning, 2016-02-29) to\n>     submodule_update_clone struct and initialized to false. When c9911c93\n>     (submodule--helper: teach update_data more options, 2022-03-15) moved it\n>     to update_data struct, it started to initialize it to true but this\n>     change was not explained in its log message.\n>     \n>     The member is set to true only when pathspec was given, and is used when\n>     a submodule that matched the pathspec is found uninitialized to give\n>     diagnostic message. \"submodule update\" without pathspec is supposed to\n>     iterate over all submodules (i.e. without pathspec limitation) and\n>     update only the initialized submodules, and finding uninitialized\n>     submodules during the iteration is a totally expected and normal thing\n>     that should not be warned.\n>     \n>     Signed-off-by: Orgad Shaneh orgads@gmail.com\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v2\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v2\n> Pull-Request: https://github.com/git/git/pull/1258\n>\n> Range-diff vs v1:\n>\n>  1:  089a52a50b4 ! 1:  1e34c9cad18 submodule--helper: fix initialization of warn_if_uninitialized\n>      @@ Metadata\n>        ## Commit message ##\n>           submodule--helper: fix initialization of warn_if_uninitialized\n>       \n>      -    This field is supposed to be off by default, and it is only enabled when\n>      -    running `git submodule update <path>`, and path is not initialized.\n>      +    The .warn_if_uninitialized member was introduced by 48308681\n>      +    (git submodule update: have a dedicated helper for cloning,\n>      +    2016-02-29) to submodule_update_clone struct and initialized to\n>      +    false.  When c9911c93 (submodule--helper: teach update_data more\n>      +    options, 2022-03-15) moved it to update_data struct, it started\n>      +    to initialize it to true but this change was not explained in\n>      +    its log message.\n>       \n>      -    Commit c9911c9358 changed it to enabled by default. This affects for\n>      -    example git checkout, which displays the following warning for each\n>      -    uninitialized submodule:\n>      -\n>      -    Submodule path 'sub' not initialized\n>      -    Maybe you want to use 'update --init'?\n>      -\n>      -    Amends c9911c9358e611390e2444f718c73900d17d3d60.\n>      +    The member is set to true only when pathspec was given, and is\n>      +    used when a submodule that matched the pathspec is found\n>      +    uninitialized to give diagnostic message.  \"submodule update\"\n>      +    without pathspec is supposed to iterate over all submodules\n>      +    (i.e. without pathspec limitation) and update only the\n>      +    initialized submodules, and finding uninitialized submodules\n>      +    during the iteration is a totally expected and normal thing that\n>      +    should not be warned.\n>       \n>           Signed-off-by: Orgad Shaneh <orgads@gmail.com>\n>       \n>      @@ builtin/submodule--helper.c: struct update_data {\n>        \t.single_branch = -1, \\\n>        \t.max_jobs = 1, \\\n>       -\t.warn_if_uninitialized = 1, \\\n>      -+\t.warn_if_uninitialized = 0, \\\n>        }\n>        \n>        static void next_submodule_warn_missing(struct submodule_update_clone *suc,\n>\n>\n>  builtin/submodule--helper.c | 1 -\n>  1 file changed, 1 deletion(-)\n>\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index 2c87ef9364f..1a8e5d06214 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -2026,7 +2026,6 @@ struct update_data {\n>  \t.references = STRING_LIST_INIT_DUP, \\\n>  \t.single_branch = -1, \\\n>  \t.max_jobs = 1, \\\n> -\t.warn_if_uninitialized = 1, \\\n>  }\n>  \n>  static void next_submodule_warn_missing(struct submodule_update_clone *suc,\n>\n> base-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e\n> -- \n> gitgitgadget\n\nThis was clearly a mistake on my part :( The fix looks good to me,\nthanks!\n"},{"id":"454559","messageId":"kl6la6c6p3iz.fsf@chooglen-macbookpro.roam.corp.google.com","threadId":"57788","inReplyTo":"xmqqtuagvq4n.fsf@gitster.g","subject":"Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Glen Choo","fromEmail":"chooglen@google.com","sentAt":"2022-04-27T22:25:40Z","receivedAt":"2022-04-27T22:25:50Z","isPatch":true,"sender":{"key":"glencbz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58092771?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Is this a fix we can protect from future breakge by adding a test or\n>> tweaking an existing test?  It is kind of surprising if we did not\n>> have any test that runs \"git submodule update\" in a superproject\n>> with initialized and uninitialized submodule(s) and make sure only\n>> the initialized ones are updated.  It may be the matter of examining\n>> the warning output that is currently ignored in such a test, if\n>> there is one.\n>\n> Here is a quick-and-dirty one I came up with.  The superproject\n> \"super\" has a handful of submodules (\"submodule\" and \"rebasing\"\n> being two of them), so the new tests clone the superproject and\n> initializes only one submodule.  Then we see how \"submodule update\"\n> with pathspec works with these two submodules (one initialied and\n> the other not).  In another test, we see how \"submodule update\"\n> without pathspec works.\n>\n> I'll queue this on top of your fix for now tentatively.  If nobody\n> finds flaws in them, I'll just squash it in soonish before merging\n> the whole thing for the maintenance track.\n>\n> Thanks.\n\nThanks for adding the tests!\n\n>  t/t7406-submodule-update.sh | 33 +++++++++++++++++++++++++++++++++\n>  1 file changed, 33 insertions(+)\n>\n> diff --git c/t/t7406-submodule-update.sh w/t/t7406-submodule-update.sh\n> index 000e055811..43f779d751 100755\n> --- c/t/t7406-submodule-update.sh\n> +++ w/t/t7406-submodule-update.sh\n> @@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '\n>  \t)\n>  '\n>  \n> +test_expect_success 'submodule update with pathspec warns against uninitialized ones' '\n> +\ttest_when_finished \"rm -fr selective\" &&\n> +\tgit clone super selective &&\n> +\t(\n> +\t\tcd selective &&\n> +\t\tgit submodule init submodule &&\n> +\n> +\t\tgit submodule update submodule 2>err &&\n> +\t\t! grep \"Submodule path .* not initialized\" err &&\n> +\n> +\t\tgit submodule update rebasing 2>err &&\n> +\t\tgrep \"Submodule path .rebasing. not initialized\" err &&\n> +\n> +\t\ttest_path_exists submodule/.git &&\n> +\t\ttest_path_is_missing rebasing/.git\n> +\t)\n> +\n> +'\n> +\n> +test_expect_success 'submodule update without pathspec updates only initialized ones' '\n> +\ttest_when_finished \"rm -fr selective\" &&\n> +\tgit clone super selective &&\n> +\t(\n> +\t\tcd selective &&\n> +\t\tgit submodule init submodule &&\n> +\t\tgit submodule update 2>err &&\n> +\t\ttest_path_exists submodule/.git &&\n> +\t\ttest_path_is_missing rebasing/.git &&\n> +\t\t! grep \"Submodule path .* not initialized\" err\n> +\t)\n> +\n> +'\n> +\n>  test_expect_success 'submodule update continues after checkout error' '\n>  \t(cd super &&\n>  \t git reset --hard HEAD &&\n\nSo we test that we only issue the warning when a pathspec is given, and\nthat we ignore uninitialized submodules when no pathspec is given. I\nthink this covers all of the cases, so this looks good, thanks!\n"},{"id":"454562","messageId":"xmqqee1ijepa.fsf@gitster.g","threadId":"57788","inReplyTo":"kl6lfslyp3ti.fsf@chooglen-macbookpro.roam.corp.google.com","subject":"Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-04-27T23:20:49Z","receivedAt":"2022-04-27T23:21:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Glen Choo <chooglen@google.com> writes:\n\n> \"Orgad Shaneh via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n>> index 2c87ef9364f..1a8e5d06214 100644\n>> --- a/builtin/submodule--helper.c\n>> +++ b/builtin/submodule--helper.c\n>> @@ -2026,7 +2026,6 @@ struct update_data {\n>>  \t.references = STRING_LIST_INIT_DUP, \\\n>>  \t.single_branch = -1, \\\n>>  \t.max_jobs = 1, \\\n>> -\t.warn_if_uninitialized = 1, \\\n>>  }\n>>  \n>>  static void next_submodule_warn_missing(struct submodule_update_clone *suc,\n>>\n>> base-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e\n>> -- \n>> gitgitgadget\n>\n> This was clearly a mistake on my part :( The fix looks good to me,\n> thanks!\n\nWill merge the fix down in preparation for 2.36.1 and later.\n\nThanks, both.\n"}]}