Skip to content

Implement (almost) all global options #1409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ambv
Copy link

@ambv ambv commented Aug 11, 2025

This pull request is split into two commits, doing those things:

Commit 1: moves option handling from the Python C API to CFFI

This simplifies future edits and removes some static typing weirdness around the _pygit2.pyi file needing Python-level enums to express the C-level functional API.

Mostly, this moves pygit2 in the direction of being more CFFI, which will eventually lead to beautiful things like not needing to push new wheels every time a new version of Python comes out (i.e. #1046).

This diff is actually red (more lines removed than added).

Commit 2: implements all remaining options

...save for GIT_OPT_SET_ALLOCATOR, which I'm pretty confident is useless for Python users, and next to impossible to get right.

But other options that were missing so far are handled, including three network related that I was really looking forward to:

  • SET_SERVER_TIMEOUT,
  • SET_SERVER_CONNECT_TIMEOUT, and
  • ENABLE_HTTP_EXPECT_CONTINUE.

All new options have a corresponding test.

@@ -145,7 +145,7 @@ class StrArray:

__array: 'GitStrrayC | ffi.NULL_TYPE'
__strings: list['None | ArrayC[char]']
__arr: 'ArrayC[char]'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A strarray is an array of strings, not a single string.

@@ -178,7 +178,7 @@ if [ -n "$LIBGIT2_VERSION" ]; then
wget https://github.com/libgit2/libgit2/archive/refs/tags/v$LIBGIT2_VERSION.tar.gz -N -O $FILENAME.tar.gz
tar xf $FILENAME.tar.gz
cd $FILENAME
mkdir build -p
mkdir -p build
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise this fails on macOS where mkdir doesn't use the GNU version.

@ambv
Copy link
Author

ambv commented Aug 12, 2025

I can reproduce the openssl segfault on Ubuntu with:

$ ci/cp310/bin/pytest test/test_options.py::test_add_ssl_x509_cert test/test_settings.py::test_ssl_methods

...

test/test_options.py::test_add_ssl_x509_cert PASSED
test/test_settings.py::test_ssl_methods Fatal Python error: Segmentation fault

Current thread 0x0000ffffa870f420 (most recent call first):
  File "/home/ubuntu/pygit2/pygit2/options.py", line 815 in option
  File "/home/ubuntu/pygit2/pygit2/settings.py", line 253 in add_ssl_x509_cert

...

So far I had a test with a dummy cert there, which looks like it's harmful. Let me adjust this one test to add an actual cert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant