cache-tree tests: use a sub-shell with less indirection
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sat, 23 Jan 2021 13:00:39 +0000 (14:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 23 Jan 2021 21:25:12 +0000 (13:25 -0800)
commitfa6edee7765028daa8c69051b404c8374d0c2a04
treebf21da6f36fd069c6849b365e7cd8e1cef8fe420
parent32267255070604efe0672793a1bbb797558765bc
cache-tree tests: use a sub-shell with less indirection

Change a "cd xyz && work && cd .." pattern introduced in
9c4d6c0297 (cache-tree: Write updated cache-tree after commit,
2014-07-13) to use a sub-shell instead with less indirection.

We did actually recover correctly if we failed in this function since
we were wrapped in a subshell one function call up. Let's just use the
sub-shell at the point where we want to change the directory
instead.

It's important that the "|| return 1" is outside the
subshell. Normally, we `exit 1` from within subshells[1], but that
wouldn't help us exit this loop early[1][2].

Since we can get rid of the wrapper function let's rename the main
function to drop the "rec" (for "recursion") suffix[3].

1. https://lore.kernel.org/git/CAPig+cToj8nQmyBCqC1k7DXF2vXaonCEA-fCJ4x7JBZG2ixYBw@mail.gmail.com/
2. https://lore.kernel.org/git/20150325052952.GE31924@peff.net/
3. https://lore.kernel.org/git/YARsCsgXuiXr4uFX@coredump.intra.peff.net/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0090-cache-tree.sh