e75d2f7f73
Extend the the release_revisions() function so that it frees the "filter" in the "struct rev_info". This in combination with a preceding change to free "cmdline" means that we can mark another set of tests as passing under "TEST_PASSES_SANITIZE_LEAK=true". The "filter" member was added recently inffaa137f64
(revision: put object filter into struct rev_info, 2022-03-09), and this fixes leaks intruded in the subsequent leak7940941de1
(pack-objects: use rev.filter when possible, 2022-03-09) and105c6f14ad
(bundle: parse filter capability, 2022-03-09). The "builtin/pack-objects.c" leak in7940941de1
was effectively with us already, but the variable was referred to by a "static" file-scoped variable. The "bundle.c " leak in105c6f14ad
was newly introduced with the new "filter" feature for bundles. The "t5600-clone-fail-cleanup.sh" change here to add "TEST_PASSES_SANITIZE_LEAK=true" is one of the cases where run-command.c in not carrying the abort() exit code upwards would have had that test passing before, but now it *actually* passes[1]. We should fix the lack of 1=1 mapping of SANITIZE=leak testing to actual leaks some other time, but it's an existing edge case, let's just mark the really-passing test as passing for now. 1. https://lore.kernel.org/git/220303.86fsnz5o9w.gmgdl@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
146 lines
4.3 KiB
Bash
Executable File
146 lines
4.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='exercise delta islands'
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
# returns true iff $1 is a delta based on $2
|
|
is_delta_base () {
|
|
delta_base=$(echo "$1" | git cat-file --batch-check='%(deltabase)') &&
|
|
echo >&2 "$1 has base $delta_base" &&
|
|
test "$delta_base" = "$2"
|
|
}
|
|
|
|
# generate a commit on branch $1 with a single file, "file", whose
|
|
# content is mostly based on the seed $2, but with a unique bit
|
|
# of content $3 appended. This should allow us to see whether
|
|
# blobs of different refs delta against each other.
|
|
commit() {
|
|
blob=$({ test-tool genrandom "$2" 10240 && echo "$3"; } |
|
|
git hash-object -w --stdin) &&
|
|
tree=$(printf '100644 blob %s\tfile\n' "$blob" | git mktree) &&
|
|
commit=$(echo "$2-$3" | git commit-tree "$tree" ${4:+-p "$4"}) &&
|
|
git update-ref "refs/heads/$1" "$commit" &&
|
|
eval "$1"'=$(git rev-parse $1:file)' &&
|
|
eval "echo >&2 $1=\$$1"
|
|
}
|
|
|
|
test_expect_success 'setup commits' '
|
|
commit one seed 1 &&
|
|
commit two seed 12
|
|
'
|
|
|
|
# Note: This is heavily dependent on the "prefer larger objects as base"
|
|
# heuristic.
|
|
test_expect_success 'vanilla repack deltas one against two' '
|
|
git repack -adf &&
|
|
is_delta_base $one $two
|
|
'
|
|
|
|
test_expect_success 'island repack with no island definition is vanilla' '
|
|
git repack -adfi &&
|
|
is_delta_base $one $two
|
|
'
|
|
|
|
test_expect_success 'island repack with no matches is vanilla' '
|
|
git -c "pack.island=refs/foo" repack -adfi &&
|
|
is_delta_base $one $two
|
|
'
|
|
|
|
test_expect_success 'separate islands disallows delta' '
|
|
git -c "pack.island=refs/heads/(.*)" repack -adfi &&
|
|
! is_delta_base $one $two &&
|
|
! is_delta_base $two $one
|
|
'
|
|
|
|
test_expect_success 'same island allows delta' '
|
|
git -c "pack.island=refs/heads" repack -adfi &&
|
|
is_delta_base $one $two
|
|
'
|
|
|
|
test_expect_success 'coalesce same-named islands' '
|
|
git \
|
|
-c "pack.island=refs/(.*)/one" \
|
|
-c "pack.island=refs/(.*)/two" \
|
|
repack -adfi &&
|
|
is_delta_base $one $two
|
|
'
|
|
|
|
test_expect_success 'island restrictions drop reused deltas' '
|
|
git repack -adfi &&
|
|
is_delta_base $one $two &&
|
|
git -c "pack.island=refs/heads/(.*)" repack -adi &&
|
|
! is_delta_base $one $two &&
|
|
! is_delta_base $two $one
|
|
'
|
|
|
|
test_expect_success 'island regexes are left-anchored' '
|
|
git -c "pack.island=heads/(.*)" repack -adfi &&
|
|
is_delta_base $one $two
|
|
'
|
|
|
|
test_expect_success 'island regexes follow last-one-wins scheme' '
|
|
git \
|
|
-c "pack.island=refs/heads/(.*)" \
|
|
-c "pack.island=refs/heads/" \
|
|
repack -adfi &&
|
|
is_delta_base $one $two
|
|
'
|
|
|
|
test_expect_success 'setup shared history' '
|
|
commit root shared root &&
|
|
commit one shared 1 root &&
|
|
commit two shared 12-long root
|
|
'
|
|
|
|
# We know that $two will be preferred as a base from $one,
|
|
# because we can transform it with a pure deletion.
|
|
#
|
|
# We also expect $root as a delta against $two by the "longest is base" rule.
|
|
test_expect_success 'vanilla delta goes between branches' '
|
|
git repack -adf &&
|
|
is_delta_base $one $two &&
|
|
is_delta_base $root $two
|
|
'
|
|
|
|
# Here we should allow $one to base itself on $root; even though
|
|
# they are in different islands, the objects in $root are in a superset
|
|
# of islands compared to those in $one.
|
|
#
|
|
# Similarly, $two can delta against $root by our rules. And unlike $one,
|
|
# in which we are just allowing it, the island rules actually put $root
|
|
# as a possible base for $two, which it would not otherwise be (due to the size
|
|
# sorting).
|
|
test_expect_success 'deltas allowed against superset islands' '
|
|
git -c "pack.island=refs/heads/(.*)" repack -adfi &&
|
|
is_delta_base $one $root &&
|
|
is_delta_base $two $root
|
|
'
|
|
|
|
# We are going to test the packfile order here, so we again have to make some
|
|
# assumptions. We assume that "$root", as part of our core "one", must come
|
|
# before "$two". This should be guaranteed by the island code. However, for
|
|
# this test to fail without islands, we are also assuming that it would not
|
|
# otherwise do so. This is true by the current write order, which will put
|
|
# commits (and their contents) before their parents.
|
|
test_expect_success 'island core places core objects first' '
|
|
cat >expect <<-EOF &&
|
|
$root
|
|
$two
|
|
EOF
|
|
git -c "pack.island=refs/heads/(.*)" \
|
|
-c "pack.islandcore=one" \
|
|
repack -adfi &&
|
|
git verify-pack -v .git/objects/pack/*.pack |
|
|
cut -d" " -f1 |
|
|
egrep "$root|$two" >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'unmatched island core is not fatal' '
|
|
git -c "pack.islandcore=one" repack -adfi
|
|
'
|
|
|
|
test_done
|