t4216: test changed path filters with high bit paths

Subsequent commits will teach Git another version of changed path filter that has different behavior with paths that contain at least one character with its high bit set, so test the existing behavior as a baseline. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Jun 25, 2024 at 13:39 UTC 08b6ae38c6024e05407fd1d1703d7e176102241b
1 file changed +51
t/t4216-log-bloom.sh
+51
@@ -488,6 +488,57 @@ test_expect_success 'merge graph layers with incompatible Bloom settings' '
488 test_must_be_empty err
489 '
490
491 +get_first_changed_path_filter () {
492 + test-tool read-graph bloom-filters >filters.dat &&
493 + head -n 1 filters.dat
494 +}
495 +
496 +# chosen to be the same under all Unicode normalization forms
497 +CENT=$(printf "\302\242")
498 +
499 +test_expect_success 'set up repo with high bit path, version 1 changed-path' '
500 + git init highbit1 &&
501 + test_commit -C highbit1 c1 "$CENT" &&
502 + git -C highbit1 commit-graph write --reachable --changed-paths
503 +'
504 +
505 +test_expect_success 'setup check value of version 1 changed-path' '
506 + (
507 + cd highbit1 &&
508 + echo "52a9" >expect &&
509 + get_first_changed_path_filter >actual
510 + )
511 +'
512 +
513 +# expect will not match actual if char is unsigned by default. Write the test
514 +# in this way, so that a user running this test script can still see if the two
515 +# files match. (It will appear as an ordinary success if they match, and a skip
516 +# if not.)
517 +if test_cmp highbit1/expect highbit1/actual
518 +then
519 + test_set_prereq SIGNED_CHAR_BY_DEFAULT
520 +fi
521 +test_expect_success SIGNED_CHAR_BY_DEFAULT 'check value of version 1 changed-path' '
522 + # Only the prereq matters for this test.
523 + true
524 +'
525 +
526 +test_expect_success 'setup make another commit' '
527 + # "git log" does not use Bloom filters for root commits - see how, in
528 + # revision.c, rev_compare_tree() (the only code path that eventually calls
529 + # get_bloom_filter()) is only called by try_to_simplify_commit() when the commit
530 + # has one parent. Therefore, make another commit so that we perform the tests on
531 + # a non-root commit.
532 + test_commit -C highbit1 anotherc1 "another$CENT"
533 +'
534 +
535 +test_expect_success 'version 1 changed-path used when version 1 requested' '
536 + (
537 + cd highbit1 &&
538 + test_bloom_filters_used "-- another$CENT"
539 + )
540 +'
541 +
542 corrupt_graph () {
543 test_when_finished "rm -rf $graph" &&
544 git commit-graph write --reachable --changed-paths &&