From: Zach FettersMoore <zach.fetters@xxxxxxxxxxxxxxxxx> Adding a test to validate that the proposed fix solves the issue. The test accomplishes this by checking the output of the split command to ensure the output from the progress of 'process_split_commit' function that represents the 'extracount' of commits processed does not increment. This was tested against the original functionality to show the test failed, and then with this fix to show the test passes. This illustrated that when using multiple subtrees, A and B, when doing a split on subtree B, the processing does not traverse the entire history of subtree A which is unnecessary and would cause the 'extracount' of processed commits to climb based on the number of commits in the history of subtree A. Signed-off-by: Zach FettersMoore <zach.fetters@xxxxxxxxxxxxxxxxx> --- contrib/subtree/t/t7900-subtree.sh | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh index 49a21dd7c9c..57c12e9f924 100755 --- a/contrib/subtree/t/t7900-subtree.sh +++ b/contrib/subtree/t/t7900-subtree.sh @@ -385,6 +385,47 @@ test_expect_success 'split sub dir/ with --rejoin' ' ) ' +test_expect_success 'split with multiple subtrees' ' + subtree_test_create_repo "$test_count" && + subtree_test_create_repo "$test_count/subA" && + subtree_test_create_repo "$test_count/subB" && + test_create_commit "$test_count" main1 && + test_create_commit "$test_count/subA" subA1 && + test_create_commit "$test_count/subA" subA2 && + test_create_commit "$test_count/subA" subA3 && + test_create_commit "$test_count/subB" subB1 && + ( + cd "$test_count" && + git fetch ./subA HEAD && + git subtree add --prefix=subADir FETCH_HEAD + ) && + ( + cd "$test_count" && + git fetch ./subB HEAD && + git subtree add --prefix=subBDir FETCH_HEAD + ) && + test_create_commit "$test_count" subADir/main-subA1 && + test_create_commit "$test_count" subBDir/main-subB1 && + ( + cd "$test_count" && + git subtree split --prefix=subADir --squash --rejoin -m "Sub A Split 1" + ) && + ( + cd "$test_count" && + git subtree split --prefix=subBDir --squash --rejoin -m "Sub B Split 1" + ) && + test_create_commit "$test_count" subADir/main-subA2 && + test_create_commit "$test_count" subBDir/main-subB2 && + ( + cd "$test_count" && + git subtree split --prefix=subADir --squash --rejoin -m "Sub A Split 2" + ) && + ( + cd "$test_count" && + test "$(git subtree split --prefix=subBDir --squash --rejoin -d -m "Sub B Split 1" 2>&1 | grep -w "\[1\]")" = "" + ) +' + test_expect_success 'split sub dir/ with --rejoin from scratch' ' subtree_test_create_repo "$test_count" && test_create_commit "$test_count" main1 && -- gitgitgadget