Amend an existing commit by replacing only explicitly passed values, return the rewritten commit's oid. This creates a new commit that is exactly the same as the old commit, except that any explicitly passed values will be updated. The new commit has the sam
(
self,
commit: Commit | Oid | str,
refname: Reference | str | None,
author: Signature | None = None,
committer: Signature | None = None,
message: str | None = None,
tree: Tree | Oid | str | None = None,
encoding: str = 'UTF-8',
)
| 1653 | # Amend commit |
| 1654 | # |
| 1655 | def amend_commit( |
| 1656 | self, |
| 1657 | commit: Commit | Oid | str, |
| 1658 | refname: Reference | str | None, |
| 1659 | author: Signature | None = None, |
| 1660 | committer: Signature | None = None, |
| 1661 | message: str | None = None, |
| 1662 | tree: Tree | Oid | str | None = None, |
| 1663 | encoding: str = 'UTF-8', |
| 1664 | ) -> Oid: |
| 1665 | """ |
| 1666 | Amend an existing commit by replacing only explicitly passed values, |
| 1667 | return the rewritten commit's oid. |
| 1668 | |
| 1669 | This creates a new commit that is exactly the same as the old commit, |
| 1670 | except that any explicitly passed values will be updated. The new |
| 1671 | commit has the same parents as the old commit. |
| 1672 | |
| 1673 | You may omit the `author`, `committer`, `message`, `tree`, and |
| 1674 | `encoding` parameters, in which case this will use the values |
| 1675 | from the original `commit`. |
| 1676 | |
| 1677 | Parameters: |
| 1678 | |
| 1679 | commit : Commit, Oid, or str |
| 1680 | The commit to amend. |
| 1681 | |
| 1682 | refname : Reference or str |
| 1683 | If not `None`, name of the reference that will be updated to point |
| 1684 | to the newly rewritten commit. Use "HEAD" to update the HEAD of the |
| 1685 | current branch and make it point to the rewritten commit. |
| 1686 | If you want to amend a commit that is not currently the tip of the |
| 1687 | branch and then rewrite the following commits to reach a ref, pass |
| 1688 | this as `None` and update the rest of the commit chain and ref |
| 1689 | separately. |
| 1690 | |
| 1691 | author : Signature |
| 1692 | If not None, replace the old commit's author signature with this |
| 1693 | one. |
| 1694 | |
| 1695 | committer : Signature |
| 1696 | If not None, replace the old commit's committer signature with this |
| 1697 | one. |
| 1698 | |
| 1699 | message : str |
| 1700 | If not None, replace the old commit's message with this one. |
| 1701 | |
| 1702 | tree : Tree, Oid, or str |
| 1703 | If not None, replace the old commit's tree with this one. |
| 1704 | |
| 1705 | encoding : str |
| 1706 | Optional encoding for `message`. |
| 1707 | """ |
| 1708 | |
| 1709 | # Initialize parameters to pass on to C function git_commit_amend. |
| 1710 | # Note: the pointers are all initialized to NULL by default. |
| 1711 | coid = ffi.new('git_oid *') |
| 1712 | commit_cptr = ffi.new('git_commit **') |