Jeff King [off-list ref] writes:
Check out some of the older scripts in contrib/examples. Several of them
require_work_tree, but do not cd_to_toplevel immediately; instead, they
do it much later for some specific bits.
Another datapoint I found was "clean".
It used to say "you have to be inside work tree" in the scripted version.
Imagine what builtin/clean.c does today? It has NEED_WORK_TREE bit in the
command table in git.c and that bit means "We need to have a work tree
that we can later chdir to if we wanted to".