From: Junio C Hamano Date: Thu, 15 Oct 2026 19:13:13 GMT Subject: Re: [PATCH] refs: fix loose-ref seeking across directory boundaries Message-ID: In-Reply-To: <20261015133624.82112-1-haraldnordgren@gmail.com> Harald Nordgren writes: > The general idea looks sound. > >> + if test "$storage" = mixed >> + then >> + git pack-refs --all || return 1 >> + fi && > > I don't see any reason why a test would need an if block, we know what data we > expect, no? This is three tests implemented as a single test with a for-loop around it. The variable instructs the single test_expect_success to behave slightly differently depending on its setting. +for storage in loose packed mixed +do + test_expect_success "start after respects directory boundaries ($storage)" ' + test_when_finished "rm -rf repo" && + git init repo && + ( + cd repo && + test_commit --no-tag base && + git update-ref refs/tags/packed HEAD && + if test "$storage" = mixed + then + git pack-refs --all || return 1 + fi && + git update-ref --stdin <<-\EOF && + create refs/tags/a-leaf HEAD + ... + EOF + if test "$storage" = packed + then + git pack-refs --all || return 1 + fi && + ... real test in the repository begins ... + ) + ' +done It creates a tag "packed", and packs when storage is "mixed". Then we create many other refs, and packs the whole refs when storage is "packed". So during these three runs of the for-loop, the preparation part quoted above behaves this way: storage=loose no 'git pack-refs' run and every ref is loose storage=packed the later 'git pack-refs' packs everything storage=mixed 'packed' tag is packed, everything else is loose and the test checks what happens in this repository with refs packed in three different ways.