libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.58k stars 382 forks source link

Add Repository.revert() #1297

Closed jorio closed 1 month ago

jorio commented 1 month ago

This exposes libgit2's git_revert(), which produces changes in the index and working directory. It also affects the repository's state (via .git/REVERT_HEAD) and prepared message (via .git/MERGE_MSG).

Rationale for adding this even though Repository.revert_commit() already exists: revert_commit() is a binding for git_revert_commit(), which is less powerful -- it doesn't check out the resulting index, and it doesn't modify the state and prepared message.


Note: git_revert() accepts additional checkout/revert settings. We could implement support for these as extra arguments to Repository.revert() in the future.