@@ -11,6 +11,7 @@ and push subcommands of git subtree.
1111
1212TEST_DIRECTORY=$( pwd) /../../../t
1313. " $TEST_DIRECTORY " /test-lib.sh
14+ . " $TEST_DIRECTORY " /lib-gpg.sh
1415
1516# Use our own wrapper around test-lib.sh's test_create_repo, in order
1617# to set log.date=relative. `git subtree` parses the output of `git
@@ -1563,4 +1564,116 @@ test_expect_success 'subtree descendant check' '
15631564 )
15641565'
15651566
1567+ test_expect_success GPG ' add subproj with GPG signing using -S flag' '
1568+ subtree_test_create_repo "$test_count" &&
1569+ subtree_test_create_repo "$test_count/sub proj" &&
1570+ test_create_commit "$test_count" main1 &&
1571+ test_create_commit "$test_count/sub proj" sub1 &&
1572+ (
1573+ cd "$test_count" &&
1574+ git fetch ./"sub proj" HEAD &&
1575+ git subtree add --prefix="sub dir" -S FETCH_HEAD &&
1576+ git verify-commit HEAD &&
1577+ test "$(last_commit_subject)" = "Add ' \' ' sub dir/' \' ' from commit ' \' ' $(git rev-parse FETCH_HEAD)' \' ' "
1578+ )
1579+ '
1580+
1581+ test_expect_success GPG ' add subproj with GPG signing using --gpg-sign flag' '
1582+ subtree_test_create_repo "$test_count" &&
1583+ subtree_test_create_repo "$test_count/sub proj" &&
1584+ test_create_commit "$test_count" main1 &&
1585+ test_create_commit "$test_count/sub proj" sub1 &&
1586+ (
1587+ cd "$test_count" &&
1588+ git fetch ./"sub proj" HEAD &&
1589+ git subtree add --prefix="sub dir" --gpg-sign FETCH_HEAD &&
1590+ git verify-commit HEAD &&
1591+ test "$(last_commit_subject)" = "Add ' \' ' sub dir/' \' ' from commit ' \' ' $(git rev-parse FETCH_HEAD)' \' ' "
1592+ )
1593+ '
1594+
1595+ test_expect_success GPG ' add subproj with GPG signing using specific key ID' '
1596+ subtree_test_create_repo "$test_count" &&
1597+ subtree_test_create_repo "$test_count/sub proj" &&
1598+ test_create_commit "$test_count" main1 &&
1599+ test_create_commit "$test_count/sub proj" sub1 &&
1600+ (
1601+ cd "$test_count" &&
1602+ git fetch ./"sub proj" HEAD &&
1603+ git subtree add --prefix="sub dir" -S"$GIT_COMMITTER_EMAIL" FETCH_HEAD &&
1604+ git verify-commit HEAD &&
1605+ test "$(last_commit_subject)" = "Add ' \' ' sub dir/' \' ' from commit ' \' ' $(git rev-parse FETCH_HEAD)' \' ' "
1606+ )
1607+ '
1608+
1609+ test_expect_success GPG ' merge with GPG signing' '
1610+ subtree_test_create_repo "$test_count" &&
1611+ subtree_test_create_repo "$test_count/sub proj" &&
1612+ test_create_commit "$test_count" main1 &&
1613+ test_create_commit "$test_count/sub proj" sub1 &&
1614+ (
1615+ cd "$test_count" &&
1616+ git fetch ./"sub proj" HEAD &&
1617+ git subtree add --prefix="sub dir" FETCH_HEAD
1618+ ) &&
1619+ test_create_commit "$test_count/sub proj" sub2 &&
1620+ (
1621+ cd "$test_count" &&
1622+ git fetch ./"sub proj" HEAD &&
1623+ git subtree merge --prefix="sub dir" -S FETCH_HEAD &&
1624+ git verify-commit HEAD
1625+ )
1626+ '
1627+
1628+ test_expect_success GPG ' split with GPG signing and --rejoin' '
1629+ subtree_test_create_repo "$test_count" &&
1630+ subtree_test_create_repo "$test_count/sub proj" &&
1631+ test_create_commit "$test_count" main1 &&
1632+ test_create_commit "$test_count/sub proj" sub1 &&
1633+ (
1634+ cd "$test_count" &&
1635+ git fetch ./"sub proj" HEAD &&
1636+ git subtree add --prefix="sub dir" FETCH_HEAD
1637+ ) &&
1638+ test_create_commit "$test_count" "sub dir/main-sub1" &&
1639+ (
1640+ cd "$test_count" &&
1641+ git subtree split --prefix="sub dir" --rejoin -S &&
1642+ git verify-commit HEAD
1643+ )
1644+ '
1645+
1646+ test_expect_success GPG ' add with --squash and GPG signing' '
1647+ subtree_test_create_repo "$test_count" &&
1648+ subtree_test_create_repo "$test_count/sub proj" &&
1649+ test_create_commit "$test_count" main1 &&
1650+ test_create_commit "$test_count/sub proj" sub1 &&
1651+ (
1652+ cd "$test_count" &&
1653+ git fetch ./"sub proj" HEAD &&
1654+ git subtree add --prefix="sub dir" --squash -S FETCH_HEAD &&
1655+ git verify-commit HEAD &&
1656+ # With --squash, the commit subject should reference the squash commit (first parent of merge)
1657+ squash_commit=$(git rev-parse HEAD^2) &&
1658+ test "$(last_commit_subject)" = "Merge commit ' \' ' $squash_commit' \' ' as ' \' ' sub dir' \' ' "
1659+ )
1660+ '
1661+
1662+ test_expect_success GPG ' pull with GPG signing' '
1663+ subtree_test_create_repo "$test_count" &&
1664+ subtree_test_create_repo "$test_count/sub proj" &&
1665+ test_create_commit "$test_count" main1 &&
1666+ test_create_commit "$test_count/sub proj" sub1 &&
1667+ (
1668+ cd "$test_count" &&
1669+ git subtree add --prefix="sub dir" ./"sub proj" HEAD
1670+ ) &&
1671+ test_create_commit "$test_count/sub proj" sub2 &&
1672+ (
1673+ cd "$test_count" &&
1674+ git subtree pull --prefix="sub dir" -S ./"sub proj" HEAD &&
1675+ git verify-commit HEAD
1676+ )
1677+ '
1678+
15661679test_done
0 commit comments