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>
409 lines
12 KiB
Bash
Executable File
409 lines
12 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git log for a path with Bloom filters'
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
. ./test-lib.sh
|
|
|
|
GIT_TEST_COMMIT_GRAPH=0
|
|
GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
|
|
|
|
test_expect_success 'setup test - repo, commits, commit graph, log outputs' '
|
|
git init &&
|
|
mkdir A A/B A/B/C &&
|
|
test_commit c1 A/file1 &&
|
|
test_commit c2 A/B/file2 &&
|
|
test_commit c3 A/B/C/file3 &&
|
|
test_commit c4 A/file1 &&
|
|
test_commit c5 A/B/file2 &&
|
|
test_commit c6 A/B/C/file3 &&
|
|
test_commit c7 A/file1 &&
|
|
test_commit c8 A/B/file2 &&
|
|
test_commit c9 A/B/C/file3 &&
|
|
test_commit c10 file_to_be_deleted &&
|
|
git checkout -b side HEAD~4 &&
|
|
test_commit side-1 file4 &&
|
|
git checkout master &&
|
|
git merge side &&
|
|
test_commit c11 file5 &&
|
|
mv file5 file5_renamed &&
|
|
git add file5_renamed &&
|
|
git commit -m "rename" &&
|
|
rm file_to_be_deleted &&
|
|
git add . &&
|
|
git commit -m "file removed" &&
|
|
git commit --allow-empty -m "empty" &&
|
|
git commit-graph write --reachable --changed-paths &&
|
|
|
|
test_oid_cache <<-EOF
|
|
oid_version sha1:1
|
|
oid_version sha256:2
|
|
EOF
|
|
'
|
|
|
|
graph_read_expect () {
|
|
NUM_CHUNKS=5
|
|
cat >expect <<- EOF
|
|
header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
|
|
num_commits: $1
|
|
chunks: oid_fanout oid_lookup commit_metadata bloom_indexes bloom_data
|
|
EOF
|
|
test-tool read-graph >actual &&
|
|
test_cmp expect actual
|
|
}
|
|
|
|
test_expect_success 'commit-graph write wrote out the bloom chunks' '
|
|
graph_read_expect 16
|
|
'
|
|
|
|
# Turn off any inherited trace2 settings for this test.
|
|
sane_unset GIT_TRACE2 GIT_TRACE2_PERF GIT_TRACE2_EVENT
|
|
sane_unset GIT_TRACE2_PERF_BRIEF
|
|
sane_unset GIT_TRACE2_CONFIG_PARAMS
|
|
|
|
setup () {
|
|
rm -f "$TRASH_DIRECTORY/trace.perf" &&
|
|
git -c core.commitGraph=false log --pretty="format:%s" $1 >log_wo_bloom &&
|
|
GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.perf" git -c core.commitGraph=true log --pretty="format:%s" $1 >log_w_bloom
|
|
}
|
|
|
|
test_bloom_filters_used () {
|
|
log_args=$1
|
|
bloom_trace_prefix="statistics:{\"filter_not_present\":${2:-0},\"maybe\""
|
|
setup "$log_args" &&
|
|
grep -q "$bloom_trace_prefix" "$TRASH_DIRECTORY/trace.perf" &&
|
|
test_cmp log_wo_bloom log_w_bloom &&
|
|
test_path_is_file "$TRASH_DIRECTORY/trace.perf"
|
|
}
|
|
|
|
test_bloom_filters_not_used () {
|
|
log_args=$1
|
|
setup "$log_args" &&
|
|
! grep -q "statistics:{\"filter_not_present\":" "$TRASH_DIRECTORY/trace.perf" &&
|
|
test_cmp log_wo_bloom log_w_bloom
|
|
}
|
|
|
|
for path in A A/B A/B/C A/file1 A/B/file2 A/B/C/file3 file4 file5 file5_renamed file_to_be_deleted
|
|
do
|
|
for option in "" \
|
|
"--all" \
|
|
"--full-history" \
|
|
"--full-history --simplify-merges" \
|
|
"--simplify-merges" \
|
|
"--simplify-by-decoration" \
|
|
"--follow" \
|
|
"--first-parent" \
|
|
"--topo-order" \
|
|
"--date-order" \
|
|
"--author-date-order" \
|
|
"--ancestry-path side..master"
|
|
do
|
|
test_expect_success "git log option: $option for path: $path" '
|
|
test_bloom_filters_used "$option -- $path" &&
|
|
test_config commitgraph.readChangedPaths false &&
|
|
test_bloom_filters_not_used "$option -- $path"
|
|
'
|
|
done
|
|
done
|
|
|
|
test_expect_success 'git log -- folder works with and without the trailing slash' '
|
|
test_bloom_filters_used "-- A" &&
|
|
test_bloom_filters_used "-- A/"
|
|
'
|
|
|
|
test_expect_success 'git log for path that does not exist. ' '
|
|
test_bloom_filters_used "-- path_does_not_exist"
|
|
'
|
|
|
|
test_expect_success 'git log with --walk-reflogs does not use Bloom filters' '
|
|
test_bloom_filters_not_used "--walk-reflogs -- A"
|
|
'
|
|
|
|
test_expect_success 'git log -- multiple path specs does not use Bloom filters' '
|
|
test_bloom_filters_not_used "-- file4 A/file1"
|
|
'
|
|
|
|
test_expect_success 'git log -- "." pathspec at root does not use Bloom filters' '
|
|
test_bloom_filters_not_used "-- ."
|
|
'
|
|
|
|
test_expect_success 'git log with wildcard that resolves to a single path uses Bloom filters' '
|
|
test_bloom_filters_used "-- *4" &&
|
|
test_bloom_filters_used "-- *renamed"
|
|
'
|
|
|
|
test_expect_success 'git log with wildcard that resolves to a multiple paths does not uses Bloom filters' '
|
|
test_bloom_filters_not_used "-- *" &&
|
|
test_bloom_filters_not_used "-- file*"
|
|
'
|
|
|
|
test_expect_success 'setup - add commit-graph to the chain without Bloom filters' '
|
|
test_commit c14 A/anotherFile2 &&
|
|
test_commit c15 A/B/anotherFile2 &&
|
|
test_commit c16 A/B/C/anotherFile2 &&
|
|
git commit-graph write --reachable --split --no-changed-paths &&
|
|
test_line_count = 2 .git/objects/info/commit-graphs/commit-graph-chain
|
|
'
|
|
|
|
test_expect_success 'use Bloom filters even if the latest graph does not have Bloom filters' '
|
|
# Ensure that the number of empty filters is equal to the number of
|
|
# filters in the latest graph layer to prove that they are loaded (and
|
|
# ignored).
|
|
test_bloom_filters_used "-- A/B" 3
|
|
'
|
|
|
|
test_expect_success 'setup - add commit-graph to the chain with Bloom filters' '
|
|
test_commit c17 A/anotherFile3 &&
|
|
git commit-graph write --reachable --changed-paths --split &&
|
|
test_line_count = 3 .git/objects/info/commit-graphs/commit-graph-chain
|
|
'
|
|
|
|
test_bloom_filters_used_when_some_filters_are_missing () {
|
|
log_args=$1
|
|
bloom_trace_prefix="statistics:{\"filter_not_present\":3,\"maybe\":6,\"definitely_not\":9"
|
|
setup "$log_args" &&
|
|
grep -q "$bloom_trace_prefix" "$TRASH_DIRECTORY/trace.perf" &&
|
|
test_cmp log_wo_bloom log_w_bloom
|
|
}
|
|
|
|
test_expect_success 'Use Bloom filters if they exist in the latest but not all commit graphs in the chain.' '
|
|
test_bloom_filters_used_when_some_filters_are_missing "-- A/B"
|
|
'
|
|
|
|
test_expect_success 'persist filter settings' '
|
|
test_when_finished rm -rf .git/objects/info/commit-graph* &&
|
|
rm -rf .git/objects/info/commit-graph* &&
|
|
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
|
|
GIT_TRACE2_EVENT_NESTING=5 \
|
|
GIT_TEST_BLOOM_SETTINGS_NUM_HASHES=9 \
|
|
GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY=15 \
|
|
git commit-graph write --reachable --changed-paths &&
|
|
grep "{\"hash_version\":1,\"num_hashes\":9,\"bits_per_entry\":15,\"max_changed_paths\":512" trace2.txt &&
|
|
GIT_TRACE2_EVENT="$(pwd)/trace2-auto.txt" \
|
|
GIT_TRACE2_EVENT_NESTING=5 \
|
|
git commit-graph write --reachable --changed-paths &&
|
|
grep "{\"hash_version\":1,\"num_hashes\":9,\"bits_per_entry\":15,\"max_changed_paths\":512" trace2-auto.txt
|
|
'
|
|
|
|
test_max_changed_paths () {
|
|
grep "\"max_changed_paths\":$1" $2
|
|
}
|
|
|
|
test_filter_not_computed () {
|
|
grep "\"key\":\"filter-not-computed\",\"value\":\"$1\"" $2
|
|
}
|
|
|
|
test_filter_computed () {
|
|
grep "\"key\":\"filter-computed\",\"value\":\"$1\"" $2
|
|
}
|
|
|
|
test_filter_trunc_empty () {
|
|
grep "\"key\":\"filter-trunc-empty\",\"value\":\"$1\"" $2
|
|
}
|
|
|
|
test_filter_trunc_large () {
|
|
grep "\"key\":\"filter-trunc-large\",\"value\":\"$1\"" $2
|
|
}
|
|
|
|
test_expect_success 'correctly report changes over limit' '
|
|
git init limits &&
|
|
(
|
|
cd limits &&
|
|
mkdir d &&
|
|
mkdir d/e &&
|
|
|
|
for i in $(test_seq 1 2)
|
|
do
|
|
printf $i >d/file$i.txt &&
|
|
printf $i >d/e/file$i.txt || return 1
|
|
done &&
|
|
|
|
mkdir mode &&
|
|
printf bash >mode/script.sh &&
|
|
|
|
mkdir foo &&
|
|
touch foo/bar &&
|
|
touch foo.txt &&
|
|
|
|
git add d foo foo.txt mode &&
|
|
git commit -m "files" &&
|
|
|
|
# Commit has 7 file and 4 directory adds
|
|
GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS=10 \
|
|
GIT_TRACE2_EVENT="$(pwd)/trace" \
|
|
git commit-graph write --reachable --changed-paths &&
|
|
test_max_changed_paths 10 trace &&
|
|
test_filter_computed 1 trace &&
|
|
test_filter_trunc_large 1 trace &&
|
|
|
|
for path in $(git ls-tree -r --name-only HEAD)
|
|
do
|
|
git -c commitGraph.readChangedPaths=false log \
|
|
-- $path >expect &&
|
|
git log -- $path >actual &&
|
|
test_cmp expect actual || return 1
|
|
done &&
|
|
|
|
# Make a variety of path changes
|
|
printf new1 >d/e/file1.txt &&
|
|
printf new2 >d/file2.txt &&
|
|
rm d/e/file2.txt &&
|
|
rm -r foo &&
|
|
printf text >foo &&
|
|
mkdir f &&
|
|
printf new1 >f/file1.txt &&
|
|
|
|
# including a mode-only change (counts as modified)
|
|
git update-index --chmod=+x mode/script.sh &&
|
|
|
|
git add foo d f &&
|
|
git commit -m "complicated" &&
|
|
|
|
# start from scratch and rebuild
|
|
rm -f .git/objects/info/commit-graph &&
|
|
GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS=10 \
|
|
GIT_TRACE2_EVENT="$(pwd)/trace-edit" \
|
|
git commit-graph write --reachable --changed-paths &&
|
|
test_max_changed_paths 10 trace-edit &&
|
|
test_filter_computed 2 trace-edit &&
|
|
test_filter_trunc_large 2 trace-edit &&
|
|
|
|
for path in $(git ls-tree -r --name-only HEAD)
|
|
do
|
|
git -c commitGraph.readChangedPaths=false log \
|
|
-- $path >expect &&
|
|
git log -- $path >actual &&
|
|
test_cmp expect actual || return 1
|
|
done &&
|
|
|
|
# start from scratch and rebuild
|
|
rm -f .git/objects/info/commit-graph &&
|
|
GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS=11 \
|
|
GIT_TRACE2_EVENT="$(pwd)/trace-update" \
|
|
git commit-graph write --reachable --changed-paths &&
|
|
test_max_changed_paths 11 trace-update &&
|
|
test_filter_computed 2 trace-update &&
|
|
test_filter_trunc_large 0 trace-update &&
|
|
|
|
for path in $(git ls-tree -r --name-only HEAD)
|
|
do
|
|
git -c commitGraph.readChangedPaths=false log \
|
|
-- $path >expect &&
|
|
git log -- $path >actual &&
|
|
test_cmp expect actual || return 1
|
|
done
|
|
)
|
|
'
|
|
|
|
test_expect_success 'correctly report commits with no changed paths' '
|
|
git init empty &&
|
|
test_when_finished "rm -fr empty" &&
|
|
(
|
|
cd empty &&
|
|
|
|
git commit --allow-empty -m "initial commit" &&
|
|
|
|
GIT_TRACE2_EVENT="$(pwd)/trace.event" \
|
|
git commit-graph write --reachable --changed-paths &&
|
|
test_filter_computed 1 trace.event &&
|
|
test_filter_not_computed 0 trace.event &&
|
|
test_filter_trunc_empty 1 trace.event &&
|
|
test_filter_trunc_large 0 trace.event
|
|
)
|
|
'
|
|
|
|
test_expect_success 'Bloom generation is limited by --max-new-filters' '
|
|
(
|
|
cd limits &&
|
|
test_commit c2 filter &&
|
|
test_commit c3 filter &&
|
|
test_commit c4 no-filter &&
|
|
|
|
rm -f trace.event &&
|
|
GIT_TRACE2_EVENT="$(pwd)/trace.event" \
|
|
git commit-graph write --reachable --split=replace \
|
|
--changed-paths --max-new-filters=2 &&
|
|
|
|
test_filter_computed 2 trace.event &&
|
|
test_filter_not_computed 3 trace.event &&
|
|
test_filter_trunc_empty 0 trace.event &&
|
|
test_filter_trunc_large 0 trace.event
|
|
)
|
|
'
|
|
|
|
test_expect_success 'Bloom generation backfills previously-skipped filters' '
|
|
# Check specifying commitGraph.maxNewFilters over "git config" works.
|
|
test_config -C limits commitGraph.maxNewFilters 1 &&
|
|
(
|
|
cd limits &&
|
|
|
|
rm -f trace.event &&
|
|
GIT_TRACE2_EVENT="$(pwd)/trace.event" \
|
|
git commit-graph write --reachable --changed-paths \
|
|
--split=replace &&
|
|
test_filter_computed 1 trace.event &&
|
|
test_filter_not_computed 4 trace.event &&
|
|
test_filter_trunc_empty 0 trace.event &&
|
|
test_filter_trunc_large 0 trace.event
|
|
)
|
|
'
|
|
|
|
test_expect_success '--max-new-filters overrides configuration' '
|
|
git init override &&
|
|
test_when_finished "rm -fr override" &&
|
|
test_config -C override commitGraph.maxNewFilters 2 &&
|
|
(
|
|
cd override &&
|
|
test_commit one &&
|
|
test_commit two &&
|
|
|
|
rm -f trace.event &&
|
|
GIT_TRACE2_EVENT="$(pwd)/trace.event" \
|
|
git commit-graph write --reachable --changed-paths \
|
|
--max-new-filters=1 &&
|
|
test_filter_computed 1 trace.event &&
|
|
test_filter_not_computed 1 trace.event &&
|
|
test_filter_trunc_empty 0 trace.event &&
|
|
test_filter_trunc_large 0 trace.event
|
|
)
|
|
'
|
|
|
|
test_expect_success 'Bloom generation backfills empty commits' '
|
|
git init empty &&
|
|
test_when_finished "rm -fr empty" &&
|
|
(
|
|
cd empty &&
|
|
for i in $(test_seq 1 6)
|
|
do
|
|
git commit --allow-empty -m "$i"
|
|
done &&
|
|
|
|
# Generate Bloom filters for empty commits 1-6, two at a time.
|
|
for i in $(test_seq 1 3)
|
|
do
|
|
rm -f trace.event &&
|
|
GIT_TRACE2_EVENT="$(pwd)/trace.event" \
|
|
git commit-graph write --reachable \
|
|
--changed-paths --max-new-filters=2 &&
|
|
test_filter_computed 2 trace.event &&
|
|
test_filter_not_computed 4 trace.event &&
|
|
test_filter_trunc_empty 2 trace.event &&
|
|
test_filter_trunc_large 0 trace.event
|
|
done &&
|
|
|
|
# Finally, make sure that once all commits have filters, that
|
|
# none are subsequently recomputed.
|
|
rm -f trace.event &&
|
|
GIT_TRACE2_EVENT="$(pwd)/trace.event" \
|
|
git commit-graph write --reachable \
|
|
--changed-paths --max-new-filters=2 &&
|
|
test_filter_computed 0 trace.event &&
|
|
test_filter_not_computed 6 trace.event &&
|
|
test_filter_trunc_empty 0 trace.event &&
|
|
test_filter_trunc_large 0 trace.event
|
|
)
|
|
'
|
|
|
|
test_done
|