Index: GitPython-3.1.58/conftest.py
===================================================================
--- /dev/null
+++ GitPython-3.1.58/conftest.py
@@ -0,0 +1,25 @@
+import os
+import pytest
+
+@pytest.hookimpl(tryfirst=True, hookwrapper=True)
+def pytest_runtest_makereport(item, call):
+    # Execute all other hooks to obtain the report object
+    outcome = yield
+    report = outcome.get_result()
+
+    # We only care if the test actually failed
+    if report.failed:
+        # Check environment variable (bypasses any command-line parsing issues)
+        xfail_msg = os.environ.get("PYTEST_XFAIL_MSG")
+
+        if xfail_msg and call.excinfo is not None:
+            # Extract the exact error message
+            error_message = str(call.excinfo.value)
+
+            # For debugging: Uncomment this to see what pytest is actually catching
+            # print(f"\n[DEBUG] Caught error: {error_message}")
+
+            if xfail_msg in error_message:
+                # Forcibly change the test result to an XFAIL
+                report.outcome = "skipped"
+                report.wasxfail = f"Dynamically xfailed due to matching error: '{xfail_msg}'"
