contrib/subtree: test history depth

Add history depth checks to some of the subtree unit tests. These checks were previously introduced as part of 28a7e27cff (contrib/subtree: detect rewritten subtree commits, 2026-01-09), which has since been reverted. Signed-off-by: Colin Stagner <ask+git@howdoi.land> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Colin Stagner committed Feb 17, 2026 at 20:31 UTC 715b406e47d51a6f4f6be3b0ed42cfbd59217258
1 file changed +16 -6
contrib/subtree/t/t7900-subtree.sh
+16 -6
@@ -411,8 +411,9 @@ test_expect_success 'split sub dir/ with --rejoin' '
411 git fetch ./"sub proj" HEAD &&
412 git subtree merge --prefix="sub dir" FETCH_HEAD &&
413 split_hash=$(git subtree split --prefix="sub dir" --annotate="*") &&
414 - git subtree split --prefix="sub dir" --annotate="*" --rejoin &&
415 - test "$(last_commit_subject)" = "Split '\''sub dir/'\'' into commit '\''$split_hash'\''"
414 + git subtree split --prefix="sub dir" --annotate="*" -b spl --rejoin &&
415 + test "$(last_commit_subject)" = "Split '\''sub dir/'\'' into commit '\''$split_hash'\''" &&
416 + test "$(git rev-list --count spl)" -eq 5
417 )
418 '
419
@@ -442,18 +443,25 @@ test_expect_success 'split with multiple subtrees' '
443 git -C "$test_count" subtree add --prefix=subADir FETCH_HEAD &&
444 git -C "$test_count" fetch ./subB HEAD &&
445 git -C "$test_count" subtree add --prefix=subBDir FETCH_HEAD &&
446 + test "$(git -C "$test_count" rev-list --count main)" -eq 7 &&
447 test_create_commit "$test_count" subADir/main-subA1 &&
448 test_create_commit "$test_count" subBDir/main-subB1 &&
449 git -C "$test_count" subtree split --prefix=subADir \
448 - --squash --rejoin -m "Sub A Split 1" &&
450 + --squash --rejoin -m "Sub A Split 1" -b a1 &&
451 + test "$(git -C "$test_count" rev-list --count main..a1)" -eq 1 &&
452 git -C "$test_count" subtree split --prefix=subBDir \
450 - --squash --rejoin -m "Sub B Split 1" &&
453 + --squash --rejoin -m "Sub B Split 1" -b b1 &&
454 + test "$(git -C "$test_count" rev-list --count main..b1)" -eq 1 &&
455 test_create_commit "$test_count" subADir/main-subA2 &&
456 test_create_commit "$test_count" subBDir/main-subB2 &&
457 git -C "$test_count" subtree split --prefix=subADir \
454 - --squash --rejoin -m "Sub A Split 2" &&
458 + --squash --rejoin -m "Sub A Split 2" -b a2 &&
459 + test "$(git -C "$test_count" rev-list --count main..a2)" -eq 2 &&
460 + test "$(git -C "$test_count" rev-list --count a1..a2)" -eq 1 &&
461 test "$(git -C "$test_count" subtree split --prefix=subBDir \
456 - --squash --rejoin -d -m "Sub B Split 1" 2>&1 | grep -w "\[1\]")" = ""
462 + --squash --rejoin -d -m "Sub B Split 1" -b b2 2>&1 | grep -w "\[1\]")" = "" &&
463 + test "$(git -C "$test_count" rev-list --count main..b2)" -eq 2 &&
464 + test "$(git -C "$test_count" rev-list --count b1..b2)" -eq 1
465 '
466
467 # When subtree split-ing a directory that has other subtree
@@ -477,6 +485,7 @@ do
485 test_path_is_file subA/file1.t &&
486 test_path_is_file subA/subB/file2.t &&
487 git subtree split --prefix=subA --branch=bsplit &&
488 + test "$(git rev-list --count bsplit)" -eq 2 &&
489 git checkout bsplit &&
490 test_path_is_file file1.t &&
491 test_path_is_file subB/file2.t &&
@@ -489,6 +498,7 @@ do
498 --prefix=subA/subB mksubtree &&
499 test_path_is_file subA/subB/file3.t &&
500 git subtree split --prefix=subA --branch=bsplit &&
501 + test "$(git rev-list --count bsplit)" -eq 3 &&
502 git checkout bsplit &&
503 test_path_is_file file1.t &&
504 test_path_is_file subB/file2.t &&