@@ -385,6 +385,46 @@ test_expect_success 'split sub dir/ with --rejoin' '
385385 )
386386'
387387
388+ # Tests that commits from other subtrees are not processed as
389+ # part of a split.
390+ #
391+ # This test performs the following:
392+ # - Creates Repo with subtrees 'subA' and 'subB'
393+ # - Creates commits in the repo including changes to subtrees
394+ # - Runs the following 'split' and commit' commands in order:
395+ # - Perform 'split' on subtree A
396+ # - Perform 'split' on subtree B
397+ # - Create new commits with changes to subtree A and B
398+ # - Perform split on subtree A
399+ # - Check that the commits in subtree B are not processed
400+ # as part of the subtree A split
401+ test_expect_success ' split with multiple subtrees' '
402+ subtree_test_create_repo "$test_count" &&
403+ subtree_test_create_repo "$test_count/subA" &&
404+ subtree_test_create_repo "$test_count/subB" &&
405+ test_create_commit "$test_count" main1 &&
406+ test_create_commit "$test_count/subA" subA1 &&
407+ test_create_commit "$test_count/subA" subA2 &&
408+ test_create_commit "$test_count/subA" subA3 &&
409+ test_create_commit "$test_count/subB" subB1 &&
410+ git -C "$test_count" fetch ./subA HEAD &&
411+ git -C "$test_count" subtree add --prefix=subADir FETCH_HEAD &&
412+ git -C "$test_count" fetch ./subB HEAD &&
413+ git -C "$test_count" subtree add --prefix=subBDir FETCH_HEAD &&
414+ test_create_commit "$test_count" subADir/main-subA1 &&
415+ test_create_commit "$test_count" subBDir/main-subB1 &&
416+ git -C "$test_count" subtree split --prefix=subADir \
417+ --squash --rejoin -m "Sub A Split 1" &&
418+ git -C "$test_count" subtree split --prefix=subBDir \
419+ --squash --rejoin -m "Sub B Split 1" &&
420+ test_create_commit "$test_count" subADir/main-subA2 &&
421+ test_create_commit "$test_count" subBDir/main-subB2 &&
422+ git -C "$test_count" subtree split --prefix=subADir \
423+ --squash --rejoin -m "Sub A Split 2" &&
424+ test "$(git -C "$test_count" subtree split --prefix=subBDir \
425+ --squash --rejoin -d -m "Sub B Split 1" 2>&1 | grep -w "\[1\]")" = ""
426+ '
427+
388428test_expect_success ' split sub dir/ with --rejoin from scratch' '
389429 subtree_test_create_repo "$test_count" &&
390430 test_create_commit "$test_count" main1 &&
0 commit comments