@@ -411,9 +411,8 @@ 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="*" -b spl --rejoin &&
415- test "$(last_commit_subject)" = "Split ' \' ' sub dir/' \' ' into commit ' \' ' $split_hash' \' ' " &&
416- test "$(git rev-list --count spl)" -eq 5
414+ git subtree split --prefix="sub dir" --annotate="*" --rejoin &&
415+ test "$(last_commit_subject)" = "Split ' \' ' sub dir/' \' ' into commit ' \' ' $split_hash' \' ' "
417416 )
418417'
419418
@@ -443,25 +442,18 @@ test_expect_success 'split with multiple subtrees' '
443442 git -C "$test_count" subtree add --prefix=subADir FETCH_HEAD &&
444443 git -C "$test_count" fetch ./subB HEAD &&
445444 git -C "$test_count" subtree add --prefix=subBDir FETCH_HEAD &&
446- test "$(git -C "$test_count" rev-list --count main)" -eq 7 &&
447445 test_create_commit "$test_count" subADir/main-subA1 &&
448446 test_create_commit "$test_count" subBDir/main-subB1 &&
449447 git -C "$test_count" subtree split --prefix=subADir \
450- --squash --rejoin -m "Sub A Split 1" -b a1 &&
451- test "$(git -C "$test_count" rev-list --count main..a1)" -eq 1 &&
448+ --squash --rejoin -m "Sub A Split 1" &&
452449 git -C "$test_count" subtree split --prefix=subBDir \
453- --squash --rejoin -m "Sub B Split 1" -b b1 &&
454- test "$(git -C "$test_count" rev-list --count main..b1)" -eq 1 &&
450+ --squash --rejoin -m "Sub B Split 1" &&
455451 test_create_commit "$test_count" subADir/main-subA2 &&
456452 test_create_commit "$test_count" subBDir/main-subB2 &&
457453 git -C "$test_count" subtree split --prefix=subADir \
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 &&
454+ --squash --rejoin -m "Sub A Split 2" &&
461455 test "$(git -C "$test_count" subtree split --prefix=subBDir \
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
456+ --squash --rejoin -d -m "Sub B Split 1" 2>&1 | grep -w "\[1\]")" = ""
465457'
466458
467459# When subtree split-ing a directory that has other subtree
485477 test_path_is_file subA/file1.t &&
486478 test_path_is_file subA/subB/file2.t &&
487479 git subtree split --prefix=subA --branch=bsplit &&
488- test "$(git rev-list --count bsplit)" -eq 2 &&
489480 git checkout bsplit &&
490481 test_path_is_file file1.t &&
491482 test_path_is_file subB/file2.t &&
498489 --prefix=subA/subB mksubtree &&
499490 test_path_is_file subA/subB/file3.t &&
500491 git subtree split --prefix=subA --branch=bsplit &&
501- test "$(git rev-list --count bsplit)" -eq 3 &&
502492 git checkout bsplit &&
503493 test_path_is_file file1.t &&
504494 test_path_is_file subB/file2.t &&
507497 '
508498done
509499
510- # Usually,
511- #
512- # git subtree merge -P subA --squash f00...
513- #
514- # makes two commits, in this order:
515- #
516- # 1. Squashed 'subA/' content from commit f00...
517- # 2. Merge commit (1) as 'subA'
518- #
519- # Commit 1 updates the subtree but does *not* rewrite paths.
520- # Commit 2 rewrites all trees to start with `subA/`
521- #
522- # Commit 1 either has no parents or depends only on other
523- # "Squashed 'subA/' content" commits.
524- #
525- # For merge without --squash, subtree produces just one commit:
526- # a merge commit with git-subtree trailers.
527- #
528- # In either case, if the user rebases these commits, they will
529- # still have the git-subtree-* trailers… but will NOT have
530- # the layout described above.
531- #
532- # Test that subsequent `git subtree split` are not confused by this.
533- test_expect_success ' split with rebased subtree commit' '
534- subtree_test_create_repo "$test_count" &&
535- (
536- cd "$test_count" &&
537- test_commit file0 &&
538- test_create_subtree_add \
539- . mksubtree subA file1 --squash &&
540- test_path_is_file subA/file1.t &&
541- mkdir subB &&
542- test_commit subB/bfile &&
543- git commit --amend -F - <<' EOF' &&
544- Squashed ' \' ' subB/' \' ' content from commit ' \' ' badf00da911bbe895347b4b236f5461d55dc9877' \' '
545-
546- Simulate a cherry-picked or rebased subtree commit.
547-
548- git-subtree-dir: subB
549- git-subtree-split: badf00da911bbe895347b4b236f5461d55dc9877
550- EOF
551- test_commit subA/file2 &&
552- test_commit subB/bfile2 &&
553- git commit --amend -F - <<' EOF' &&
554- Split ' \' ' subB/' \' ' into commit ' \' ' badf00da911bbe895347b4b236f5461d55dc9877' \' '
555-
556- Simulate a cherry-picked or rebased subtree commit.
557-
558- git-subtree-dir: subB
559- git-subtree-mainline: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
560- git-subtree-split: badf00da911bbe895347b4b236f5461d55dc9877
561- EOF
562- git subtree split --prefix=subA --branch=bsplit &&
563- git checkout bsplit &&
564- test_path_is_file file1.t &&
565- test_path_is_file file2.t &&
566- test "$(last_commit_subject)" = "subA/file2" &&
567- test "$(git rev-list --count bsplit)" -eq 2
568- )
569- '
570-
571500test_expect_success ' split sub dir/ with --rejoin from scratch' '
572501 subtree_test_create_repo "$test_count" &&
573502 test_create_commit "$test_count" main1 &&
0 commit comments