Re: [PATCH] refs: fix loose-ref seeking across directory boundaries
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 15, 2026, 19:13 UTC
- Message-ID
- <xmqqse26n5fa.fsf@gitster.g>
- In-Reply-To
- <20261015133624.82112-1-haraldnordgren@gmail.com>
Harald Nordgren <haraldnordgren@gmail.com> writes:
Show 9 quoted lines
> 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 looseand the test checks what happens in this repository with refs packed in three different ways.