git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] submodule--helper: fix initialization of warn_if_uninitialized
@ 2022-04-24  6:26 Orgad Shaneh via GitGitGadget
  2022-04-25  9:34 ` Junio C Hamano
  2022-04-25 12:45 ` [PATCH v2] " Orgad Shaneh via GitGitGadget
  0 siblings, 2 replies; 11+ messages in thread
From: Orgad Shaneh via GitGitGadget @ 2022-04-24  6:26 UTC (permalink / raw)
  To: git; +Cc: Orgad Shaneh, Orgad Shaneh

From: Orgad Shaneh <orgads@gmail.com>

This field is supposed to be off by default, and it is only enabled when
running `git submodule update <path>`, and path is not initialized.

Commit c9911c9358 changed it to enabled by default. This affects for
example git checkout, which displays the following warning for each
uninitialized submodule:

Submodule path 'sub' not initialized
Maybe you want to use 'update --init'?

Amends c9911c9358e611390e2444f718c73900d17d3d60.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
    submodule--helper: fix initialization of warn_if_uninitialized
    
    This field is supposed to be off by default, and it is only enabled when
    running git submodule update <path>, and path is not initialized.
    
    Commit c9911c9358 changed it to enabled by default. This affects for
    example git checkout, which displays the following warning for each
    uninitialized submodule:
    
    Submodule path 'sub' not initialized
    Maybe you want to use 'update --init'?
    
    
    Amends c9911c9358e611390e2444f718c73900d17d3d60.
    
    Signed-off-by: Orgad Shaneh orgads@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v1
Pull-Request: https://github.com/git/git/pull/1258

 builtin/submodule--helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 2c87ef9364f..b28112e3040 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2026,7 +2026,7 @@ struct update_data {
 	.references = STRING_LIST_INIT_DUP, \
 	.single_branch = -1, \
 	.max_jobs = 1, \
-	.warn_if_uninitialized = 1, \
+	.warn_if_uninitialized = 0, \
 }
 
 static void next_submodule_warn_missing(struct submodule_update_clone *suc,

base-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-24  6:26 [PATCH] submodule--helper: fix initialization of warn_if_uninitialized Orgad Shaneh via GitGitGadget
@ 2022-04-25  9:34 ` Junio C Hamano
  2022-04-25 12:43   ` Orgad Shaneh
  2022-04-25 12:45 ` [PATCH v2] " Orgad Shaneh via GitGitGadget
  1 sibling, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2022-04-25  9:34 UTC (permalink / raw)
  To: Orgad Shaneh via GitGitGadget, Glen Choo; +Cc: git, Orgad Shaneh

"Orgad Shaneh via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Orgad Shaneh <orgads@gmail.com>
>
> This field is supposed to be off by default, and it is only enabled when
> running `git submodule update <path>`, and path is not initialized.

"is supposed to be": can you substantiate it with evidence and
logic?

One easy way to explain the above is to examine what the default
value was before the problematic commit, and go back from that
commit to see how the default was decided, and examine how the
member is used.

> Commit c9911c9358 changed it to enabled by default. This affects
> for example git checkout, which displays the following warning for
> each uninitialized submodule:
>
> Submodule path 'sub' not initialized
> Maybe you want to use 'update --init'?

We refer to an existing commit like this:

    c9911c93 (submodule--helper: teach update_data more options,
    2022-03-15) changed it to be enabled by default.

So, taking the above together:

    The .warn_if_uninitialized member was introduced by 48308681
    (git submodule update: have a dedicated helper for cloning,
    2016-02-29) to submodule_update_clone struct and initialized to
    false.  When c9911c93 (submodule--helper: teach update_data more
    options, 2022-03-15) moved it to update_data struct, it started
    to initialize it to true but this change was not explained in
    its log message.

    The member is set to true only when pathspec was given, and is
    used when a submodule that matched the pathspec is found
    uninitialized to give diagnostic message.  "submodule update"
    without pathspec is supposed to iterate over all submodules
    (i.e. without pathspec limitation) and update only the
    initialized submodules, and finding uninitialized submodules
    during the iteration is a totally expected and normal thing that
    should not be warned.

    Fix this regression by initializing the member to 0.

> Amends c9911c9358e611390e2444f718c73900d17d3d60.

In the context of "git", the verb "amend" has a specific meaning
(i.e. "commit --amend"), and we should refrain from using it when we
are doing something else to avoid confusing readers.

We could say

    Fix this problem that was introduced by c9911c93
    (submodule--helper: teach update_data more options, 2022-03-15)

but it is not necessary, as long as we explained how that commit
broke the code to justify this change (which we should do anyway).

>
> Signed-off-by: Orgad Shaneh <orgads@gmail.com>
> ---
>     submodule--helper: fix initialization of warn_if_uninitialized
> ...
>     Signed-off-by: Orgad Shaneh orgads@gmail.com

Here under three-dash line is where you would write comment meant
for those who read the message on the list that are not necessarily
meant to be part of resulting commit.  Repeating the same message as
the log message is not desired here.

> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v1
> Pull-Request: https://github.com/git/git/pull/1258
>
>  builtin/submodule--helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 2c87ef9364f..b28112e3040 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -2026,7 +2026,7 @@ struct update_data {
>  	.references = STRING_LIST_INIT_DUP, \
>  	.single_branch = -1, \
>  	.max_jobs = 1, \
> -	.warn_if_uninitialized = 1, \
> +	.warn_if_uninitialized = 0, \
>  }

This is not wrong per-se, but omitting the mention of the member
altogether and letting the compiler initialize it to 0 would
probably be a better fix.

Thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-25  9:34 ` Junio C Hamano
@ 2022-04-25 12:43   ` Orgad Shaneh
  0 siblings, 0 replies; 11+ messages in thread
From: Orgad Shaneh @ 2022-04-25 12:43 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Orgad Shaneh via GitGitGadget, Glen Choo, git

On Mon, Apr 25, 2022 at 12:34 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Orgad Shaneh via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Orgad Shaneh <orgads@gmail.com>
> >
> > This field is supposed to be off by default, and it is only enabled when
> > running `git submodule update <path>`, and path is not initialized.
>
> "is supposed to be": can you substantiate it with evidence and
> logic?
>
> One easy way to explain the above is to examine what the default
> value was before the problematic commit, and go back from that
> commit to see how the default was decided, and examine how the
> member is used.
>
> > Commit c9911c9358 changed it to enabled by default. This affects
> > for example git checkout, which displays the following warning for
> > each uninitialized submodule:
> >
> > Submodule path 'sub' not initialized
> > Maybe you want to use 'update --init'?
>
> We refer to an existing commit like this:
>
>     c9911c93 (submodule--helper: teach update_data more options,
>     2022-03-15) changed it to be enabled by default.
>
> So, taking the above together:
>
>     The .warn_if_uninitialized member was introduced by 48308681
>     (git submodule update: have a dedicated helper for cloning,
>     2016-02-29) to submodule_update_clone struct and initialized to
>     false.  When c9911c93 (submodule--helper: teach update_data more
>     options, 2022-03-15) moved it to update_data struct, it started
>     to initialize it to true but this change was not explained in
>     its log message.
>
>     The member is set to true only when pathspec was given, and is
>     used when a submodule that matched the pathspec is found
>     uninitialized to give diagnostic message.  "submodule update"
>     without pathspec is supposed to iterate over all submodules
>     (i.e. without pathspec limitation) and update only the
>     initialized submodules, and finding uninitialized submodules
>     during the iteration is a totally expected and normal thing that
>     should not be warned.
>
>     Fix this regression by initializing the member to 0.

Thank you very much. Updated.

> > Amends c9911c9358e611390e2444f718c73900d17d3d60.
>
> In the context of "git", the verb "amend" has a specific meaning
> (i.e. "commit --amend"), and we should refrain from using it when we
> are doing something else to avoid confusing readers.
>
> We could say
>
>     Fix this problem that was introduced by c9911c93
>     (submodule--helper: teach update_data more options, 2022-03-15)
>
> but it is not necessary, as long as we explained how that commit
> broke the code to justify this change (which we should do anyway).

I'm used to this from other projects, but ok.

> > ---
> >     submodule--helper: fix initialization of warn_if_uninitialized
> > ...
> >     Signed-off-by: Orgad Shaneh orgads@gmail.com
>
> Here under three-dash line is where you would write comment meant
> for those who read the message on the list that are not necessarily
> meant to be part of resulting commit.  Repeating the same message as
> the log message is not desired here.

This was done by GitGitGadget. I have no idea how to avoid it.

> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v1
> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v1
> > Pull-Request: https://github.com/git/git/pull/1258
> >
> >  builtin/submodule--helper.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> > index 2c87ef9364f..b28112e3040 100644
> > --- a/builtin/submodule--helper.c
> > +++ b/builtin/submodule--helper.c
> > @@ -2026,7 +2026,7 @@ struct update_data {
> >       .references = STRING_LIST_INIT_DUP, \
> >       .single_branch = -1, \
> >       .max_jobs = 1, \
> > -     .warn_if_uninitialized = 1, \
> > +     .warn_if_uninitialized = 0, \
> >  }
>
> This is not wrong per-se, but omitting the mention of the member
> altogether and letting the compiler initialize it to 0 would
> probably be a better fix.

Done.

Thanks for the review.

- Orgad

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-24  6:26 [PATCH] submodule--helper: fix initialization of warn_if_uninitialized Orgad Shaneh via GitGitGadget
  2022-04-25  9:34 ` Junio C Hamano
@ 2022-04-25 12:45 ` Orgad Shaneh via GitGitGadget
  2022-04-25 18:25   ` Junio C Hamano
  2022-04-27 22:19   ` Glen Choo
  1 sibling, 2 replies; 11+ messages in thread
From: Orgad Shaneh via GitGitGadget @ 2022-04-25 12:45 UTC (permalink / raw)
  To: git; +Cc: Orgad Shaneh, Orgad Shaneh

From: Orgad Shaneh <orgads@gmail.com>

The .warn_if_uninitialized member was introduced by 48308681
(git submodule update: have a dedicated helper for cloning,
2016-02-29) to submodule_update_clone struct and initialized to
false.  When c9911c93 (submodule--helper: teach update_data more
options, 2022-03-15) moved it to update_data struct, it started
to initialize it to true but this change was not explained in
its log message.

The member is set to true only when pathspec was given, and is
used when a submodule that matched the pathspec is found
uninitialized to give diagnostic message.  "submodule update"
without pathspec is supposed to iterate over all submodules
(i.e. without pathspec limitation) and update only the
initialized submodules, and finding uninitialized submodules
during the iteration is a totally expected and normal thing that
should not be warned.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
    submodule--helper: fix initialization of warn_if_uninitialized
    
    The .warn_if_uninitialized member was introduced by 48308681 (git
    submodule update: have a dedicated helper for cloning, 2016-02-29) to
    submodule_update_clone struct and initialized to false. When c9911c93
    (submodule--helper: teach update_data more options, 2022-03-15) moved it
    to update_data struct, it started to initialize it to true but this
    change was not explained in its log message.
    
    The member is set to true only when pathspec was given, and is used when
    a submodule that matched the pathspec is found uninitialized to give
    diagnostic message. "submodule update" without pathspec is supposed to
    iterate over all submodules (i.e. without pathspec limitation) and
    update only the initialized submodules, and finding uninitialized
    submodules during the iteration is a totally expected and normal thing
    that should not be warned.
    
    Signed-off-by: Orgad Shaneh orgads@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v2
Pull-Request: https://github.com/git/git/pull/1258

Range-diff vs v1:

 1:  089a52a50b4 ! 1:  1e34c9cad18 submodule--helper: fix initialization of warn_if_uninitialized
     @@ Metadata
       ## Commit message ##
          submodule--helper: fix initialization of warn_if_uninitialized
      
     -    This field is supposed to be off by default, and it is only enabled when
     -    running `git submodule update <path>`, and path is not initialized.
     +    The .warn_if_uninitialized member was introduced by 48308681
     +    (git submodule update: have a dedicated helper for cloning,
     +    2016-02-29) to submodule_update_clone struct and initialized to
     +    false.  When c9911c93 (submodule--helper: teach update_data more
     +    options, 2022-03-15) moved it to update_data struct, it started
     +    to initialize it to true but this change was not explained in
     +    its log message.
      
     -    Commit c9911c9358 changed it to enabled by default. This affects for
     -    example git checkout, which displays the following warning for each
     -    uninitialized submodule:
     -
     -    Submodule path 'sub' not initialized
     -    Maybe you want to use 'update --init'?
     -
     -    Amends c9911c9358e611390e2444f718c73900d17d3d60.
     +    The member is set to true only when pathspec was given, and is
     +    used when a submodule that matched the pathspec is found
     +    uninitialized to give diagnostic message.  "submodule update"
     +    without pathspec is supposed to iterate over all submodules
     +    (i.e. without pathspec limitation) and update only the
     +    initialized submodules, and finding uninitialized submodules
     +    during the iteration is a totally expected and normal thing that
     +    should not be warned.
      
          Signed-off-by: Orgad Shaneh <orgads@gmail.com>
      
     @@ builtin/submodule--helper.c: struct update_data {
       	.single_branch = -1, \
       	.max_jobs = 1, \
      -	.warn_if_uninitialized = 1, \
     -+	.warn_if_uninitialized = 0, \
       }
       
       static void next_submodule_warn_missing(struct submodule_update_clone *suc,


 builtin/submodule--helper.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 2c87ef9364f..1a8e5d06214 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2026,7 +2026,6 @@ struct update_data {
 	.references = STRING_LIST_INIT_DUP, \
 	.single_branch = -1, \
 	.max_jobs = 1, \
-	.warn_if_uninitialized = 1, \
 }
 
 static void next_submodule_warn_missing(struct submodule_update_clone *suc,

base-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-25 12:45 ` [PATCH v2] " Orgad Shaneh via GitGitGadget
@ 2022-04-25 18:25   ` Junio C Hamano
  2022-04-25 20:56     ` Junio C Hamano
  2022-04-27 22:19   ` Glen Choo
  1 sibling, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2022-04-25 18:25 UTC (permalink / raw)
  To: Orgad Shaneh via GitGitGadget; +Cc: git, Orgad Shaneh, Glen Choo

"Orgad Shaneh via GitGitGadget" <gitgitgadget@gmail.com> writes:

> The member is set to true only when pathspec was given, and is
> used when a submodule that matched the pathspec is found
> uninitialized to give diagnostic message.  "submodule update"
> without pathspec is supposed to iterate over all submodules
> (i.e. without pathspec limitation) and update only the
> initialized submodules, and finding uninitialized submodules
> during the iteration is a totally expected and normal thing that
> should not be warned.
> ...
>  builtin/submodule--helper.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 2c87ef9364f..1a8e5d06214 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -2026,7 +2026,6 @@ struct update_data {
>  	.references = STRING_LIST_INIT_DUP, \
>  	.single_branch = -1, \
>  	.max_jobs = 1, \
> -	.warn_if_uninitialized = 1, \
>  }

Is this a fix we can protect from future breakge by adding a test or
tweaking an existing test?  It is kind of surprising if we did not
have any test that runs "git submodule update" in a superproject
with initialized and uninitialized submodule(s) and make sure only
the initialized ones are updated.  It may be the matter of examining
the warning output that is currently ignored in such a test, if
there is one.

Thanks.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-25 18:25   ` Junio C Hamano
@ 2022-04-25 20:56     ` Junio C Hamano
  2022-04-27 22:22       ` Glen Choo
                         ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Junio C Hamano @ 2022-04-25 20:56 UTC (permalink / raw)
  To: Orgad Shaneh via GitGitGadget; +Cc: git, Orgad Shaneh, Glen Choo

Junio C Hamano <gitster@pobox.com> writes:

> Is this a fix we can protect from future breakge by adding a test or
> tweaking an existing test?  It is kind of surprising if we did not
> have any test that runs "git submodule update" in a superproject
> with initialized and uninitialized submodule(s) and make sure only
> the initialized ones are updated.  It may be the matter of examining
> the warning output that is currently ignored in such a test, if
> there is one.

Here is a quick-and-dirty one I came up with.  The superproject
"super" has a handful of submodules ("submodule" and "rebasing"
being two of them), so the new tests clone the superproject and
initializes only one submodule.  Then we see how "submodule update"
with pathspec works with these two submodules (one initialied and
the other not).  In another test, we see how "submodule update"
without pathspec works.

I'll queue this on top of your fix for now tentatively.  If nobody
finds flaws in them, I'll just squash it in soonish before merging
the whole thing for the maintenance track.

Thanks.

 t/t7406-submodule-update.sh | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git c/t/t7406-submodule-update.sh w/t/t7406-submodule-update.sh
index 000e055811..43f779d751 100755
--- c/t/t7406-submodule-update.sh
+++ w/t/t7406-submodule-update.sh
@@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '
 	)
 '
 
+test_expect_success 'submodule update with pathspec warns against uninitialized ones' '
+	test_when_finished "rm -fr selective" &&
+	git clone super selective &&
+	(
+		cd selective &&
+		git submodule init submodule &&
+
+		git submodule update submodule 2>err &&
+		! grep "Submodule path .* not initialized" err &&
+
+		git submodule update rebasing 2>err &&
+		grep "Submodule path .rebasing. not initialized" err &&
+
+		test_path_exists submodule/.git &&
+		test_path_is_missing rebasing/.git
+	)
+
+'
+
+test_expect_success 'submodule update without pathspec updates only initialized ones' '
+	test_when_finished "rm -fr selective" &&
+	git clone super selective &&
+	(
+		cd selective &&
+		git submodule init submodule &&
+		git submodule update 2>err &&
+		test_path_exists submodule/.git &&
+		test_path_is_missing rebasing/.git &&
+		! grep "Submodule path .* not initialized" err
+	)
+
+'
+
 test_expect_success 'submodule update continues after checkout error' '
 	(cd super &&
 	 git reset --hard HEAD &&

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-25 12:45 ` [PATCH v2] " Orgad Shaneh via GitGitGadget
  2022-04-25 18:25   ` Junio C Hamano
@ 2022-04-27 22:19   ` Glen Choo
  2022-04-27 23:20     ` Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: Glen Choo @ 2022-04-27 22:19 UTC (permalink / raw)
  To: Orgad Shaneh via GitGitGadget, git; +Cc: Orgad Shaneh

"Orgad Shaneh via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Orgad Shaneh <orgads@gmail.com>
>
> The .warn_if_uninitialized member was introduced by 48308681
> (git submodule update: have a dedicated helper for cloning,
> 2016-02-29) to submodule_update_clone struct and initialized to
> false.  When c9911c93 (submodule--helper: teach update_data more
> options, 2022-03-15) moved it to update_data struct, it started
> to initialize it to true but this change was not explained in
> its log message.
>
> The member is set to true only when pathspec was given, and is
> used when a submodule that matched the pathspec is found
> uninitialized to give diagnostic message.  "submodule update"
> without pathspec is supposed to iterate over all submodules
> (i.e. without pathspec limitation) and update only the
> initialized submodules, and finding uninitialized submodules
> during the iteration is a totally expected and normal thing that
> should not be warned.
>
> Signed-off-by: Orgad Shaneh <orgads@gmail.com>
> ---
>     submodule--helper: fix initialization of warn_if_uninitialized
>     
>     The .warn_if_uninitialized member was introduced by 48308681 (git
>     submodule update: have a dedicated helper for cloning, 2016-02-29) to
>     submodule_update_clone struct and initialized to false. When c9911c93
>     (submodule--helper: teach update_data more options, 2022-03-15) moved it
>     to update_data struct, it started to initialize it to true but this
>     change was not explained in its log message.
>     
>     The member is set to true only when pathspec was given, and is used when
>     a submodule that matched the pathspec is found uninitialized to give
>     diagnostic message. "submodule update" without pathspec is supposed to
>     iterate over all submodules (i.e. without pathspec limitation) and
>     update only the initialized submodules, and finding uninitialized
>     submodules during the iteration is a totally expected and normal thing
>     that should not be warned.
>     
>     Signed-off-by: Orgad Shaneh orgads@gmail.com
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1258%2Forgads%2Fsub-no-warn-v2
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1258/orgads/sub-no-warn-v2
> Pull-Request: https://github.com/git/git/pull/1258
>
> Range-diff vs v1:
>
>  1:  089a52a50b4 ! 1:  1e34c9cad18 submodule--helper: fix initialization of warn_if_uninitialized
>      @@ Metadata
>        ## Commit message ##
>           submodule--helper: fix initialization of warn_if_uninitialized
>       
>      -    This field is supposed to be off by default, and it is only enabled when
>      -    running `git submodule update <path>`, and path is not initialized.
>      +    The .warn_if_uninitialized member was introduced by 48308681
>      +    (git submodule update: have a dedicated helper for cloning,
>      +    2016-02-29) to submodule_update_clone struct and initialized to
>      +    false.  When c9911c93 (submodule--helper: teach update_data more
>      +    options, 2022-03-15) moved it to update_data struct, it started
>      +    to initialize it to true but this change was not explained in
>      +    its log message.
>       
>      -    Commit c9911c9358 changed it to enabled by default. This affects for
>      -    example git checkout, which displays the following warning for each
>      -    uninitialized submodule:
>      -
>      -    Submodule path 'sub' not initialized
>      -    Maybe you want to use 'update --init'?
>      -
>      -    Amends c9911c9358e611390e2444f718c73900d17d3d60.
>      +    The member is set to true only when pathspec was given, and is
>      +    used when a submodule that matched the pathspec is found
>      +    uninitialized to give diagnostic message.  "submodule update"
>      +    without pathspec is supposed to iterate over all submodules
>      +    (i.e. without pathspec limitation) and update only the
>      +    initialized submodules, and finding uninitialized submodules
>      +    during the iteration is a totally expected and normal thing that
>      +    should not be warned.
>       
>           Signed-off-by: Orgad Shaneh <orgads@gmail.com>
>       
>      @@ builtin/submodule--helper.c: struct update_data {
>        	.single_branch = -1, \
>        	.max_jobs = 1, \
>       -	.warn_if_uninitialized = 1, \
>      -+	.warn_if_uninitialized = 0, \
>        }
>        
>        static void next_submodule_warn_missing(struct submodule_update_clone *suc,
>
>
>  builtin/submodule--helper.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 2c87ef9364f..1a8e5d06214 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -2026,7 +2026,6 @@ struct update_data {
>  	.references = STRING_LIST_INIT_DUP, \
>  	.single_branch = -1, \
>  	.max_jobs = 1, \
> -	.warn_if_uninitialized = 1, \
>  }
>  
>  static void next_submodule_warn_missing(struct submodule_update_clone *suc,
>
> base-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e
> -- 
> gitgitgadget

This was clearly a mistake on my part :( The fix looks good to me,
thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-25 20:56     ` Junio C Hamano
@ 2022-04-27 22:22       ` Glen Choo
  2022-04-27 22:23       ` Glen Choo
  2022-04-27 22:25       ` Glen Choo
  2 siblings, 0 replies; 11+ messages in thread
From: Glen Choo @ 2022-04-27 22:22 UTC (permalink / raw)
  To: Junio C Hamano, Orgad Shaneh via GitGitGadget; +Cc: git, Orgad Shaneh

Junio C Hamano <gitster@pobox.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> Is this a fix we can protect from future breakge by adding a test or
>> tweaking an existing test?  It is kind of surprising if we did not
>> have any test that runs "git submodule update" in a superproject
>> with initialized and uninitialized submodule(s) and make sure only
>> the initialized ones are updated.  It may be the matter of examining
>> the warning output that is currently ignored in such a test, if
>> there is one.
>
> Here is a quick-and-dirty one I came up with.  The superproject
> "super" has a handful of submodules ("submodule" and "rebasing"
> being two of them), so the new tests clone the superproject and
> initializes only one submodule.  Then we see how "submodule update"
> with pathspec works with these two submodules (one initialied and
> the other not).  In another test, we see how "submodule update"
> without pathspec works.
>
> I'll queue this on top of your fix for now tentatively.  If nobody
> finds flaws in them, I'll just squash it in soonish before merging
> the whole thing for the maintenance track.
>
> Thanks.

Thanks for adding the tests!

>  t/t7406-submodule-update.sh | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
>
> diff --git c/t/t7406-submodule-update.sh w/t/t7406-submodule-update.sh
> index 000e055811..43f779d751 100755
> --- c/t/t7406-submodule-update.sh
> +++ w/t/t7406-submodule-update.sh
> @@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '
>  	)
>  '
>  
> +test_expect_success 'submodule update with pathspec warns against uninitialized ones' '
> +	test_when_finished "rm -fr selective" &&
> +	git clone super selective &&
> +	(
> +		cd selective &&
> +		git submodule init submodule &&
> +
> +		git submodule update submodule 2>err &&
> +		! grep "Submodule path .* not initialized" err &&
> +
> +		git submodule update rebasing 2>err &&
> +		grep "Submodule path .rebasing. not initialized" err &&
> +
> +		test_path_exists submodule/.git &&
> +		test_path_is_missing rebasing/.git
> +	)
> +
> +'
> +
> +test_expect_success 'submodule update without pathspec updates only initialized ones' '
> +	test_when_finished "rm -fr selective" &&
> +	git clone super selective &&
> +	(
> +		cd selective &&
> +		git submodule init submodule &&
> +		git submodule update 2>err &&
> +		test_path_exists submodule/.git &&
> +		test_path_is_missing rebasing/.git &&
> +		! grep "Submodule path .* not initialized" err
> +	)
> +
> +'
> +
>  test_expect_success 'submodule update continues after checkout error' '
>  	(cd super &&
>  	 git reset --hard HEAD &&

So we test that we only issue the warning when a pathspec is given, and
that we ignore uninitialized submodules when no pathspec is given. I
think this covers all of the cases, so this looks good, thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-25 20:56     ` Junio C Hamano
  2022-04-27 22:22       ` Glen Choo
@ 2022-04-27 22:23       ` Glen Choo
  2022-04-27 22:25       ` Glen Choo
  2 siblings, 0 replies; 11+ messages in thread
From: Glen Choo @ 2022-04-27 22:23 UTC (permalink / raw)
  To: Junio C Hamano, Orgad Shaneh via GitGitGadget; +Cc: git, Orgad Shaneh

Junio C Hamano <gitster@pobox.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> Is this a fix we can protect from future breakge by adding a test or
>> tweaking an existing test?  It is kind of surprising if we did not
>> have any test that runs "git submodule update" in a superproject
>> with initialized and uninitialized submodule(s) and make sure only
>> the initialized ones are updated.  It may be the matter of examining
>> the warning output that is currently ignored in such a test, if
>> there is one.
>
> Here is a quick-and-dirty one I came up with.  The superproject
> "super" has a handful of submodules ("submodule" and "rebasing"
> being two of them), so the new tests clone the superproject and
> initializes only one submodule.  Then we see how "submodule update"
> with pathspec works with these two submodules (one initialied and
> the other not).  In another test, we see how "submodule update"
> without pathspec works.
>
> I'll queue this on top of your fix for now tentatively.  If nobody
> finds flaws in them, I'll just squash it in soonish before merging
> the whole thing for the maintenance track.
>
> Thanks.

Thanks for adding the tests!

>  t/t7406-submodule-update.sh | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
>
> diff --git c/t/t7406-submodule-update.sh w/t/t7406-submodule-update.sh
> index 000e055811..43f779d751 100755
> --- c/t/t7406-submodule-update.sh
> +++ w/t/t7406-submodule-update.sh
> @@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '
>  	)
>  '
>  
> +test_expect_success 'submodule update with pathspec warns against uninitialized ones' '
> +	test_when_finished "rm -fr selective" &&
> +	git clone super selective &&
> +	(
> +		cd selective &&
> +		git submodule init submodule &&
> +
> +		git submodule update submodule 2>err &&
> +		! grep "Submodule path .* not initialized" err &&
> +
> +		git submodule update rebasing 2>err &&
> +		grep "Submodule path .rebasing. not initialized" err &&
> +
> +		test_path_exists submodule/.git &&
> +		test_path_is_missing rebasing/.git
> +	)
> +
> +'
> +
> +test_expect_success 'submodule update without pathspec updates only initialized ones' '
> +	test_when_finished "rm -fr selective" &&
> +	git clone super selective &&
> +	(
> +		cd selective &&
> +		git submodule init submodule &&
> +		git submodule update 2>err &&
> +		test_path_exists submodule/.git &&
> +		test_path_is_missing rebasing/.git &&
> +		! grep "Submodule path .* not initialized" err
> +	)
> +
> +'
> +
>  test_expect_success 'submodule update continues after checkout error' '
>  	(cd super &&
>  	 git reset --hard HEAD &&

So we test that we only issue the warning when a pathspec is given, and
that we ignore uninitialized submodules when no pathspec is given. I
think this covers all of the cases, so this looks good, thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-25 20:56     ` Junio C Hamano
  2022-04-27 22:22       ` Glen Choo
  2022-04-27 22:23       ` Glen Choo
@ 2022-04-27 22:25       ` Glen Choo
  2 siblings, 0 replies; 11+ messages in thread
From: Glen Choo @ 2022-04-27 22:25 UTC (permalink / raw)
  To: Junio C Hamano, Orgad Shaneh via GitGitGadget; +Cc: git, Orgad Shaneh

Junio C Hamano <gitster@pobox.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> Is this a fix we can protect from future breakge by adding a test or
>> tweaking an existing test?  It is kind of surprising if we did not
>> have any test that runs "git submodule update" in a superproject
>> with initialized and uninitialized submodule(s) and make sure only
>> the initialized ones are updated.  It may be the matter of examining
>> the warning output that is currently ignored in such a test, if
>> there is one.
>
> Here is a quick-and-dirty one I came up with.  The superproject
> "super" has a handful of submodules ("submodule" and "rebasing"
> being two of them), so the new tests clone the superproject and
> initializes only one submodule.  Then we see how "submodule update"
> with pathspec works with these two submodules (one initialied and
> the other not).  In another test, we see how "submodule update"
> without pathspec works.
>
> I'll queue this on top of your fix for now tentatively.  If nobody
> finds flaws in them, I'll just squash it in soonish before merging
> the whole thing for the maintenance track.
>
> Thanks.

Thanks for adding the tests!

>  t/t7406-submodule-update.sh | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
>
> diff --git c/t/t7406-submodule-update.sh w/t/t7406-submodule-update.sh
> index 000e055811..43f779d751 100755
> --- c/t/t7406-submodule-update.sh
> +++ w/t/t7406-submodule-update.sh
> @@ -670,6 +670,39 @@ test_expect_success 'submodule update --init skips submodule with update=none' '
>  	)
>  '
>  
> +test_expect_success 'submodule update with pathspec warns against uninitialized ones' '
> +	test_when_finished "rm -fr selective" &&
> +	git clone super selective &&
> +	(
> +		cd selective &&
> +		git submodule init submodule &&
> +
> +		git submodule update submodule 2>err &&
> +		! grep "Submodule path .* not initialized" err &&
> +
> +		git submodule update rebasing 2>err &&
> +		grep "Submodule path .rebasing. not initialized" err &&
> +
> +		test_path_exists submodule/.git &&
> +		test_path_is_missing rebasing/.git
> +	)
> +
> +'
> +
> +test_expect_success 'submodule update without pathspec updates only initialized ones' '
> +	test_when_finished "rm -fr selective" &&
> +	git clone super selective &&
> +	(
> +		cd selective &&
> +		git submodule init submodule &&
> +		git submodule update 2>err &&
> +		test_path_exists submodule/.git &&
> +		test_path_is_missing rebasing/.git &&
> +		! grep "Submodule path .* not initialized" err
> +	)
> +
> +'
> +
>  test_expect_success 'submodule update continues after checkout error' '
>  	(cd super &&
>  	 git reset --hard HEAD &&

So we test that we only issue the warning when a pathspec is given, and
that we ignore uninitialized submodules when no pathspec is given. I
think this covers all of the cases, so this looks good, thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] submodule--helper: fix initialization of warn_if_uninitialized
  2022-04-27 22:19   ` Glen Choo
@ 2022-04-27 23:20     ` Junio C Hamano
  0 siblings, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2022-04-27 23:20 UTC (permalink / raw)
  To: Glen Choo; +Cc: Orgad Shaneh via GitGitGadget, git, Orgad Shaneh

Glen Choo <chooglen@google.com> writes:

> "Orgad Shaneh via GitGitGadget" <gitgitgadget@gmail.com> writes:
>> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
>> index 2c87ef9364f..1a8e5d06214 100644
>> --- a/builtin/submodule--helper.c
>> +++ b/builtin/submodule--helper.c
>> @@ -2026,7 +2026,6 @@ struct update_data {
>>  	.references = STRING_LIST_INIT_DUP, \
>>  	.single_branch = -1, \
>>  	.max_jobs = 1, \
>> -	.warn_if_uninitialized = 1, \
>>  }
>>  
>>  static void next_submodule_warn_missing(struct submodule_update_clone *suc,
>>
>> base-commit: 6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e
>> -- 
>> gitgitgadget
>
> This was clearly a mistake on my part :( The fix looks good to me,
> thanks!

Will merge the fix down in preparation for 2.36.1 and later.

Thanks, both.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-04-27 23:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24  6:26 [PATCH] submodule--helper: fix initialization of warn_if_uninitialized Orgad Shaneh via GitGitGadget
2022-04-25  9:34 ` Junio C Hamano
2022-04-25 12:43   ` Orgad Shaneh
2022-04-25 12:45 ` [PATCH v2] " Orgad Shaneh via GitGitGadget
2022-04-25 18:25   ` Junio C Hamano
2022-04-25 20:56     ` Junio C Hamano
2022-04-27 22:22       ` Glen Choo
2022-04-27 22:23       ` Glen Choo
2022-04-27 22:25       ` Glen Choo
2022-04-27 22:19   ` Glen Choo
2022-04-27 23:20     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).