Skip to content

Commit 715b406

Browse files
Colin Stagnergitster
authored andcommitted
contrib/subtree: test history depth
Add history depth checks to some of the subtree unit tests. These checks were previously introduced as part of 28a7e27 (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>
1 parent 767ee99 commit 715b406

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

contrib/subtree/t/t7900-subtree.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,9 @@ test_expect_success 'split sub dir/ with --rejoin' '
411411
git fetch ./"sub proj" HEAD &&
412412
git subtree merge --prefix="sub dir" FETCH_HEAD &&
413413
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
416417
)
417418
'
418419

@@ -442,18 +443,25 @@ test_expect_success 'split with multiple subtrees' '
442443
git -C "$test_count" subtree add --prefix=subADir FETCH_HEAD &&
443444
git -C "$test_count" fetch ./subB HEAD &&
444445
git -C "$test_count" subtree add --prefix=subBDir FETCH_HEAD &&
446+
test "$(git -C "$test_count" rev-list --count main)" -eq 7 &&
445447
test_create_commit "$test_count" subADir/main-subA1 &&
446448
test_create_commit "$test_count" subBDir/main-subB1 &&
447449
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 &&
449452
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 &&
451455
test_create_commit "$test_count" subADir/main-subA2 &&
452456
test_create_commit "$test_count" subBDir/main-subB2 &&
453457
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 &&
455461
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
457465
'
458466

459467
# When subtree split-ing a directory that has other subtree
@@ -477,6 +485,7 @@ do
477485
test_path_is_file subA/file1.t &&
478486
test_path_is_file subA/subB/file2.t &&
479487
git subtree split --prefix=subA --branch=bsplit &&
488+
test "$(git rev-list --count bsplit)" -eq 2 &&
480489
git checkout bsplit &&
481490
test_path_is_file file1.t &&
482491
test_path_is_file subB/file2.t &&
@@ -489,6 +498,7 @@ do
489498
--prefix=subA/subB mksubtree &&
490499
test_path_is_file subA/subB/file3.t &&
491500
git subtree split --prefix=subA --branch=bsplit &&
501+
test "$(git rev-list --count bsplit)" -eq 3 &&
492502
git checkout bsplit &&
493503
test_path_is_file file1.t &&
494504
test_path_is_file subB/file2.t &&

0 commit comments

Comments
 (0)