Merge branch 'ds/more-index-cleanups'

Cleaning various codepaths up.

* ds/more-index-cleanups:
  t1092: test interesting sparse-checkout scenarios
  test-lib: test_region looks for trace2 regions
  sparse-checkout: load sparse-checkout patterns
  name-hash: use trace2 regions for init
  repository: add repo reference to index_state
  fsmonitor: de-duplicate BUG()s around dirty bits
  cache-tree: extract subtree_pos()
  cache-tree: simplify verify_cache() prototype
  cache-tree: clean up cache_tree_update()
This commit is contained in:
Junio C Hamano
2021-02-10 14:48:32 -08:00
15 changed files with 408 additions and 53 deletions

View File

@ -1683,3 +1683,45 @@ test_subcommand () {
grep "\[$expr\]"
fi
}
# Check that the given command was invoked as part of the
# trace2-format trace on stdin.
#
# test_region [!] <category> <label> git <command> <args>...
#
# For example, to look for trace2_region_enter("index", "do_read_index", repo)
# in an invocation of "git checkout HEAD~1", run
#
# GIT_TRACE2_EVENT="$(pwd)/trace.txt" GIT_TRACE2_EVENT_NESTING=10 \
# git checkout HEAD~1 &&
# test_region index do_read_index <trace.txt
#
# If the first parameter passed is !, this instead checks that
# the given region was not entered.
#
test_region () {
local expect_exit=0
if test "$1" = "!"
then
expect_exit=1
shift
fi
grep -e '"region_enter".*"category":"'"$1"'","label":"'"$2"\" "$3"
exitcode=$?
if test $exitcode != $expect_exit
then
return 1
fi
grep -e '"region_leave".*"category":"'"$1"'","label":"'"$2"\" "$3"
exitcode=$?
if test $exitcode != $expect_exit
then
return 1
fi
return 0
}