Skip to content

Conversation

orgads
Copy link
Contributor

@orgads orgads commented Apr 24, 2022

cc: Glen Choo chooglen@google.com

@orgads
Copy link
Contributor Author

orgads commented Apr 24, 2022

/submit

@gitgitgadget-git
Copy link

Submitted as pull.1258.git.git.1650781575173.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-1258/orgads/sub-no-warn-v1

To fetch this version to local tag pr-git-1258/orgads/sub-no-warn-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-1258/orgads/sub-no-warn-v1

@gitgitgadget-git
Copy link

On the Git mailing list, Junio C Hamano wrote (reply to this):

"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.

The .warn_if_uninitialized member was introduced by 4830868
(git submodule update: have a dedicated helper for cloning,
2016-02-29) to submodule_update_clone struct and initialized to
false.  When c9911c9 (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>
@orgads
Copy link
Contributor Author

orgads commented Apr 25, 2022

/submit

@gitgitgadget-git
Copy link

Submitted as pull.1258.v2.git.git.1650890741430.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-1258/orgads/sub-no-warn-v2

To fetch this version to local tag pr-git-1258/orgads/sub-no-warn-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-1258/orgads/sub-no-warn-v2

@gitgitgadget-git
Copy link

On the Git mailing list, Orgad Shaneh wrote (reply to this):

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

@phil-blain
Copy link
Contributor

Hi @orgads, you can avoid the duplicated message by using an empty PR description here on GitGitgadget :)

@phil-blain
Copy link
Contributor

See gitgitgadget/gitgitgadget#23

@phil-blain
Copy link
Contributor

Though for later iterations, v2, v3, etc, it is recommended to use the PR description to explain what has changed since the last iteration, see https://git-scm.com/docs/MyFirstContribution#responding-ggg

@orgads
Copy link
Contributor Author

orgads commented Apr 25, 2022

Thank you.

@gitgitgadget-git
Copy link

On the Git mailing list, Junio C Hamano wrote (reply to this):

"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.


@gitgitgadget-git
Copy link

This branch is now known as gc/submodule-update-part2.

@gitgitgadget-git
Copy link

This patch series was integrated into seen via ebb5e63.

@gitgitgadget-git
Copy link

On the Git mailing list, Junio C Hamano wrote (reply to this):

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 &&

@gitgitgadget-git
Copy link

This patch series was integrated into seen via 3ee7beb.

@gitgitgadget-git
Copy link

There was a status update in the "New Topics" section about the branch gc/submodule-update-part2 on the Git mailing list:

"git submodule update" without pathspec should silently skip an
uninitialized submodule, but it started to become noisy by mistake.

Will merge to 'next' and then to 'master'.
source: <pull.1258.v2.git.git.1650890741430.gitgitgadget@gmail.com>

@gitgitgadget-git
Copy link

This patch series was integrated into seen via b4526f0.

@gitgitgadget-git
Copy link

On the Git mailing list, Glen Choo wrote (reply to this):

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!

@gitgitgadget-git
Copy link

User Glen Choo <chooglen@google.com> has been added to the cc: list.

@gitgitgadget-git
Copy link

On the Git mailing list, Glen Choo wrote (reply to this):

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!

@gitgitgadget-git
Copy link

On the Git mailing list, Glen Choo wrote (reply to this):

"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!

@gitgitgadget-git
Copy link

On the Git mailing list, Glen Choo wrote (reply to this):

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!

@gitgitgadget-git
Copy link

On the Git mailing list, Junio C Hamano wrote (reply to this):

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.

@gitgitgadget-git
Copy link

There was a status update in the "Graduated to 'master'" section about the branch gc/submodule-update-part2 on the Git mailing list:

"git submodule update" without pathspec should silently skip an
uninitialized submodule, but it started to become noisy by mistake.

This fixes a regression in 2.36 and is slate to go to 2.36.1
source: <pull.1258.v2.git.git.1650890741430.gitgitgadget@gmail.com>

@phil-blain
Copy link
Contributor

@dscho any idea why this PR does not have a master label, even though the branch was merged to master?

@dscho
Copy link
Member

dscho commented May 10, 2022

@dscho any idea why this PR does not have a master label, even though the branch was merged to master?

Honestly, I have no idea... GitGitGadget probably has the wrong idea of the tip commit. When that happens, I kind of hope for the original contributors to notice and close the PR manually.

@orgads can this be closed?

@orgads
Copy link
Contributor Author

orgads commented May 10, 2022

Sure, thanks.

@orgads orgads closed this May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants