On Mon, Dec 20, 2021 at 01:33:32PM -0500, Derrick Stolee wrote: > On 12/13/2021 8:55 PM, Taylor Blau wrote: > > To determine which source of data is used for the MIDX's reverse index > > cache, introduce a helper which forces loading the reverse index, and > > then looks for the special trace2 event introduced in a previous commit. > > > > For now, this helper just looks for when the legacy MIDX .rev file was > > loaded, but in a subsequent commit will become parameterized over the > > the reverse index's source. > > > > This function replaces checking for the existence of the .rev file. We > > could write a similar helper to ensure that the .rev file is cleaned up > > after repacking, but it will make subsequent tests more difficult to > > write, and provides marginal value since we already check that the MIDX > > .bitmap file is removed. > > ... > > > +test_rev_exists () { > > + commit="$1" > > + > > + test_expect_success 'reverse index exists' ' > > + GIT_TRACE2_EVENT_NESTING=10 \ > > Very recently, b8de3d6 (test-lib.sh: set GIT_TRACE2_EVENT_NESTING, > 2021-11-29) made it to master and sets this to 100 across the test > suite, so you don't need this line. Thanks; I had written it with this in place in case this topic was going to reach master before the topic containing b8de3d6. But it didn't, and you're right that setting GIT_TRACE2_EVENT_NESTING explicitly here is no longer necessary. > > + GIT_TRACE2_EVENT=$(pwd)/event.trace \ > > + git rev-list --test-bitmap "$commit" && > > This use of $commit has me worried. Do the tests become too flaky > to changes in how we choose commits for the bitmaps? Does that > require callers to be too aware of the refstate when creating the > bitmaps? > > Perhaps just `git rev-list --use-bitmap-index [--objects] HEAD` > would suffice to generate the trace event? It's necessary for the group of tests which exercise partial bitmap coverage (see the "setup partial bitmaps" test and below for more). In those tests, we don't have bitmap coverage of HEAD, only HEAD~, so we need to be able to say things like: test_rev_exists HEAD~ since just asking for the tip isn't guaranteed to work always. We could make the argument optional (i.e., `git rev-list --test-bitmap "${1:-HEAD}"`), but I generally find that it makes the callers more difficult to read rather than easier. On the "--test-bitmap" vs "--objects" thing, I don't think it matters either way. They are both doing basically the same traversal, but "--test-bitmap" does some additional integrity checks on top. > > test_expect_success 'create single-pack midx with bitmaps' ' > > git repack -ad && > > git multi-pack-index write --bitmap && > > test_path_is_file $midx && > > - test_path_is_file $midx-$(midx_checksum $objdir).bitmap && > > - test_path_is_file $midx-$(midx_checksum $objdir).rev > > + test_path_is_file $midx-$(midx_checksum $objdir).bitmap > > ' > > > > +test_rev_exists HEAD > > + > > Perhaps this helper would be more appropriate as a helper method > within a test, rather than creating a test of its own? I think > it looks better to include it next to the setup lines, something > like Eh, sure. I won't plan on picking this up, but I'm happy to if you feel strongly about it. Thanks, Taylor