Glen Choo <chooglen@xxxxxxxxxx> writes: > >> +# In downstream, init "submodule2", but do not check it out while > >> +# fetching. This lets us assert that unpopulated submodules can be > >> +# fetched. > >> +test_expect_success 'setup downstream branch with other submodule' ' > >> + mkdir submodule2 && > >> + ( > >> + cd submodule2 && > >> + git init && > >> + echo sub2content >sub2file && > >> + git add sub2file && > >> + git commit -a -m new && > >> + git branch -M sub2 > >> + ) && > >> + git checkout -b super-sub2-only && > >> + git submodule add "$pwd/submodule2" submodule2 && > >> + git commit -m "add sub2" && > >> + git checkout super && > >> + ( > >> + cd downstream && > >> + git fetch --recurse-submodules origin && > >> + git checkout super-sub2-only && > >> + # Explicitly run "git submodule update" because sub2 is new > >> + # and has not been cloned. > >> + git submodule update --init && > >> + git checkout --recurse-submodules super > >> + ) > >> +' > > > > Hmm...what is the difference between this and the original case in which > > the index has no submodules? Both assert that unpopulated submodules > > (submodules that cannot be found by iterating the index, as described in > > your commit message) can be fetched. > > In the previous test, the index has no submodules (it's completely empty > in fact, so we don't iterate the index at all), but in this test, it > does. This lets us check that there aren't any buggy interactions when > both changed and index submodules are present. > > I think such mistakes are pretty easy to introduce on accident - I made > one pre-v1 where I reused .count between both iterators (instead > of having .index_count and .changed_count). It passed the previous test > because we didn't care about the index, but it obviously wouldn't pass > this one. In that case, describe this difference (one has no submodules in index, one has other submodules in index) and maybe position this so that both test cases (the no-submodule-in-index one and the other-submodule-in-index one) are next to each other.