b2e5d75d17
When the "ab/various-leak-fixes" topic was merged in [1] only t6021 would fail if the tests were run in the "GIT_TEST_PASSING_SANITIZE_LEAK=check" mode, i.e. to check whether we marked all leak-free tests with "TEST_PASSES_SANITIZE_LEAK=true". Since then we've had various tests starting to pass under SANITIZE=leak. Let's mark those as passing, this is when they started to pass, narrowed down with "git bisect": - t5317-pack-objects-filter-objects.sh: Infaebba436e
(list-objects-filter: plug pattern_list leak, 2022-12-01). - t3210-pack-refs.sh, t5613-info-alternate.sh, t7403-submodule-sync.sh: In189e97bc4b
(diff: remove parseopts member from struct diff_options, 2022-12-01). - t1408-packed-refs.sh: Inab91f6b7c4
(Merge branch 'rs/diff-parseopts', 2022-12-19). - t0023-crlf-am.sh, t4152-am-subjects.sh, t4254-am-corrupt.sh, t4256-am-format-flowed.sh, t4257-am-interactive.sh, t5403-post-checkout-hook.sh: Ina658e881c1
(am: don't pass strvec to apply_parse_options(), 2022-12-13) - t1301-shared-repo.sh, t1302-repo-version.sh: Inb07a819c05
(reflog: clear leftovers in reflog_expiry_cleanup(), 2022-12-13). - t1304-default-acl.sh, t1410-reflog.sh, t5330-no-lazy-fetch-with-commit-graph.sh, t5502-quickfetch.sh, t5604-clone-reference.sh, t6014-rev-list-all.sh, t7701-repack-unpack-unreachable.sh: Inb0c61be320
(Merge branch 'rs/reflog-expiry-cleanup', 2022-12-26) - t3800-mktag.sh, t5302-pack-index.sh, t5306-pack-nobase.sh, t5573-pull-verify-signatures.sh, t7612-merge-verify-signatures.sh: In69bbbe484b
(hash-object: use fsck for object checks, 2023-01-18). - t1451-fsck-buffer.sh: In8e4309038f
(fsck: do not assume NUL-termination of buffers, 2023-01-19). - t6501-freshen-objects.sh: Inabf2bb895b
(Merge branch 'jk/hash-object-fsck', 2023-01-30) 1.9ea1378d04
(Merge branch 'ab/various-leak-fixes', 2022-12-14) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
185 lines
4.6 KiB
Bash
Executable File
185 lines
4.6 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# This test covers the handling of objects which might have old
|
|
# mtimes in the filesystem (because they were used previously)
|
|
# and are just now becoming referenced again.
|
|
#
|
|
# We're going to do two things that are a little bit "fake" to
|
|
# help make our simulation easier:
|
|
#
|
|
# 1. We'll turn off reflogs. You can still run into
|
|
# problems with reflogs on, but your objects
|
|
# don't get pruned until both the reflog expiration
|
|
# has passed on their references, _and_ they are out
|
|
# of prune's expiration period. Dropping reflogs
|
|
# means we only have to deal with one variable in our tests,
|
|
# but the results generalize.
|
|
#
|
|
# 2. We'll use a temporary index file to create our
|
|
# works-in-progress. Most workflows would mention
|
|
# referenced objects in the index, which prune takes
|
|
# into account. However, many operations don't. For
|
|
# example, a partial commit with "git commit foo"
|
|
# will use a temporary index. Or they may not need
|
|
# an index at all (e.g., creating a new commit
|
|
# to refer to an existing tree).
|
|
|
|
test_description='check pruning of dependent objects'
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./test-lib.sh
|
|
|
|
# We care about reachability, so we do not want to use
|
|
# the normal test_commit, which creates extra tags.
|
|
add () {
|
|
echo "$1" >"$1" &&
|
|
git add "$1"
|
|
}
|
|
commit () {
|
|
test_tick &&
|
|
add "$1" &&
|
|
git commit -m "$1"
|
|
}
|
|
|
|
maybe_repack () {
|
|
case "$title" in
|
|
loose)
|
|
: skip repack
|
|
;;
|
|
repack)
|
|
git repack -ad
|
|
;;
|
|
bitmap)
|
|
git repack -adb
|
|
;;
|
|
*)
|
|
echo >&2 "unknown test type in maybe_repack"
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
for title in loose repack bitmap
|
|
do
|
|
test_expect_success "make repo completely empty ($title)" '
|
|
rm -rf .git &&
|
|
git init
|
|
'
|
|
|
|
test_expect_success "disable reflogs ($title)" '
|
|
git config core.logallrefupdates false &&
|
|
git reflog expire --expire=all --all
|
|
'
|
|
|
|
test_expect_success "setup basic history ($title)" '
|
|
commit base
|
|
'
|
|
|
|
test_expect_success "create and abandon some objects ($title)" '
|
|
git checkout -b experiment &&
|
|
commit abandon &&
|
|
maybe_repack &&
|
|
git checkout main &&
|
|
git branch -D experiment
|
|
'
|
|
|
|
test_expect_success "simulate time passing ($title)" '
|
|
test-tool chmtime --get -86400 $(find .git/objects -type f)
|
|
'
|
|
|
|
test_expect_success "start writing new commit with old blob ($title)" '
|
|
tree=$(
|
|
GIT_INDEX_FILE=index.tmp &&
|
|
export GIT_INDEX_FILE &&
|
|
git read-tree HEAD &&
|
|
add unrelated &&
|
|
add abandon &&
|
|
git write-tree
|
|
)
|
|
'
|
|
|
|
test_expect_success "simultaneous gc ($title)" '
|
|
git gc --prune=12.hours.ago
|
|
'
|
|
|
|
test_expect_success "finish writing out commit ($title)" '
|
|
commit=$(echo foo | git commit-tree -p HEAD $tree) &&
|
|
git update-ref HEAD $commit
|
|
'
|
|
|
|
# "abandon" blob should have been rescued by reference from new tree
|
|
test_expect_success "repository passes fsck ($title)" '
|
|
git fsck
|
|
'
|
|
|
|
test_expect_success "abandon objects again ($title)" '
|
|
git reset --hard HEAD^ &&
|
|
test-tool chmtime --get -86400 $(find .git/objects -type f)
|
|
'
|
|
|
|
test_expect_success "start writing new commit with same tree ($title)" '
|
|
tree=$(
|
|
GIT_INDEX_FILE=index.tmp &&
|
|
export GIT_INDEX_FILE &&
|
|
git read-tree HEAD &&
|
|
add abandon &&
|
|
add unrelated &&
|
|
git write-tree
|
|
)
|
|
'
|
|
|
|
test_expect_success "simultaneous gc ($title)" '
|
|
git gc --prune=12.hours.ago
|
|
'
|
|
|
|
# tree should have been refreshed by write-tree
|
|
test_expect_success "finish writing out commit ($title)" '
|
|
commit=$(echo foo | git commit-tree -p HEAD $tree) &&
|
|
git update-ref HEAD $commit
|
|
'
|
|
done
|
|
|
|
test_expect_success 'do not complain about existing broken links (commit)' '
|
|
cat >broken-commit <<-EOF &&
|
|
tree $(test_oid 001)
|
|
parent $(test_oid 002)
|
|
author whatever <whatever@example.com> 1234 -0000
|
|
committer whatever <whatever@example.com> 1234 -0000
|
|
|
|
some message
|
|
EOF
|
|
commit=$(git hash-object -t commit -w broken-commit) &&
|
|
git gc -q 2>stderr &&
|
|
verbose git cat-file -e $commit &&
|
|
test_must_be_empty stderr
|
|
'
|
|
|
|
test_expect_success 'do not complain about existing broken links (tree)' '
|
|
cat >broken-tree <<-EOF &&
|
|
100644 blob $(test_oid 003) foo
|
|
EOF
|
|
tree=$(git mktree --missing <broken-tree) &&
|
|
git gc -q 2>stderr &&
|
|
git cat-file -e $tree &&
|
|
test_must_be_empty stderr
|
|
'
|
|
|
|
test_expect_success 'do not complain about existing broken links (tag)' '
|
|
cat >broken-tag <<-EOF &&
|
|
object $(test_oid 004)
|
|
type commit
|
|
tag broken
|
|
tagger whatever <whatever@example.com> 1234 -0000
|
|
|
|
this is a broken tag
|
|
EOF
|
|
tag=$(git hash-object -t tag -w broken-tag) &&
|
|
git gc -q 2>stderr &&
|
|
git cat-file -e $tag &&
|
|
test_must_be_empty stderr
|
|
'
|
|
|
|
test_done
|