334afbc76f
In addition to the manual adjustment to let the `linux-gcc` CI job run the test suite with `master` and then with `main`, this patch makes sure that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts that currently rely on the initial branch name being `master by default. To determine which test scripts to mark up, the first step was to force-set the default branch name to `master` in - all test scripts that contain the keyword `master`, - t4211, which expects `t/t4211/history.export` with a hard-coded ref to initialize the default branch, - t5560 because it sources `t/t556x_common` which uses `master`, - t8002 and t8012 because both source `t/annotate-tests.sh` which also uses `master`) This trick was performed by this command: $ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\ ' $(git grep -l master t/t[0-9]*.sh) \ t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh After that, careful, manual inspection revealed that some of the test scripts containing the needle `master` do not actually rely on a specific default branch name: either they mention `master` only in a comment, or they initialize that branch specificially, or they do not actually refer to the current default branch. Therefore, the aforementioned modification was undone in those test scripts thusly: $ git checkout HEAD -- \ t/t0027-auto-crlf.sh t/t0060-path-utils.sh \ t/t1011-read-tree-sparse-checkout.sh \ t/t1305-config-include.sh t/t1309-early-config.sh \ t/t1402-check-ref-format.sh t/t1450-fsck.sh \ t/t2024-checkout-dwim.sh \ t/t2106-update-index-assume-unchanged.sh \ t/t3040-subprojects-basic.sh t/t3301-notes.sh \ t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \ t/t3436-rebase-more-options.sh \ t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \ t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \ t/t5511-refspec.sh t/t5526-fetch-submodules.sh \ t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \ t/t5548-push-porcelain.sh \ t/t5552-skipping-fetch-negotiator.sh \ t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \ t/t5614-clone-submodules-shallow.sh \ t/t7508-status.sh t/t7606-merge-custom.sh \ t/t9302-fast-import-unpack-limit.sh We excluded one set of test scripts in these commands, though: the range of `git p4` tests. The reason? `git p4` stores the (foreign) remote branch in the branch called `p4/master`, which is obviously not the default branch. Manual analysis revealed that only five of these tests actually require a specific default branch name to pass; They were modified thusly: $ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\ ' t/t980[0167]*.sh t/t9811*.sh Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
174 lines
4.4 KiB
Bash
Executable File
174 lines
4.4 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=master
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
. ./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 () {
|
|
if test -n "$repack"; then
|
|
git repack -ad
|
|
fi
|
|
}
|
|
|
|
for repack in '' true; do
|
|
title=${repack:+repack}
|
|
title=${title:-loose}
|
|
|
|
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 master &&
|
|
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
|