Junio C Hamano <gitster@xxxxxxxxx> writes: > Junio C Hamano <gitster@xxxxxxxxx> 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!