libgit2 / pygit2

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

Return Python enums from _pygit2 #1263

Closed jorio closed 5 months ago

jorio commented 5 months ago

Following up on #1251: C functions in _pygit2 now return actual Python enums instead of ints.

For example, Repository.status() would previously return simple ints. Now it returns FileStatus which transparently demotes to ints for legacy code:

>>> repo.status()
{'file1.txt': <FileStatus.CONFLICTED: 32768>,
 'file2.txt': <FileStatus.INDEX_MODIFIED|WT_MODIFIED: 258>}

Implementation details: References to the enums are cached via cache_modules so that lookups are faster. The references are decref'd in free_module (new module destructor function)

Affected functions: