Skip to content

fix(util): wait for contended locks with relative filenames - #2282

Open
FanWu-ai wants to merge 2 commits into
gitpython-developers:mainfrom
FanWu-ai:fix-relative-blocking-lock-20261011
Open

FanWu-ai wants to merge 2 commits into
gitpython-developers:mainfrom
FanWu-ai:fix-relative-blocking-lock-20261011

Conversation

@FanWu-ai

@FanWu-ai FanWu-ai commented Oct 11, 2026 •

Copy link
Copy Markdown

BlockingLockFile('resource') fails immediately when another holder owns the lock, reporting that its directory is missing. dirname('resource.lock') is empty, so the directory check rejects an existing current directory.

Use the current directory when the lock path has no directory component. Seven regression cases cover relative and absolute str/Path inputs, acquisition after the holder releases, timeout reporting, and genuinely missing directories.

Validation on Linux, CPython 3.12.14 and Git 2.52.0:

  • Pristine full suite: 1,689 passed; new cases before the fix: 4 failed, 3 passed.
  • Final full suite: 1,696 passed, 89 unchanged conditional skips, 1 existing xfail, 64 subtests passed; 92% coverage.
  • All nine pinned hooks, mypy (46 files), basedpyright with warnings enabled, clean docs, wheel/sdist builds, strict Twine and whitespace checks pass.

The skips cover platform/filesystem-specific cases; the existing xfail concerns shallow submodules. The existing environment-variable path deprecation warning remains. Native Windows, macOS and Cygwin have not been run locally.

Follow-up CI compatibility repair (2026-10-12, commit 62fe322):

  • The original hosted run exposed four test failures on Python 3.8–3.10 (including Cygwin 3.9): string-based mock lookup followed the legacy git.util alias to git.index.util instead of the intended module.
  • Patch the already imported time module's sleep attribute directly. This is a one-line test-only change; the production fix and every assertion remain unchanged.
  • Fresh pristine full suites on Linux, CPython 3.8.20/3.9.25/3.10.22/3.12.14: 1,689 passed per interpreter. Final full suites: 1,696 passed per interpreter, with the same 89 skips and one existing xfail; 64 subtests pass where reported (3.10/3.12).
  • On 3.8/3.9/3.10, the corrected tests against the original production code still give 4 failed and 3 passed, preserving regression sensitivity.
  • Final nine pinned hooks, mypy on 3.9/3.10/3.12, basedpyright with warnings enabled, clean documentation builds on 3.9/3.10/3.12, wheel/sdist builds, strict Twine and whitespace checks all pass.
  • The latest five hosted workflows for this commit currently report action_required with no jobs started. Hosted CI is awaiting approval, not passing: Python package run. Earlier hosted results are not evidence that this new commit passed.

This contribution was prepared by OpenAI Codex, an AI agent operating through FanWu-ai's account. No human review or approval is claimed.

`BlockingLockFile('resource')` incorrectly treats the empty `dirname` of
`resource.lock` as a missing directory when another holder owns the lock.
Use `os.curdir` for that case so the retry and timeout paths work normally.

Add seven tests covering relative and absolute `str`/`Path` inputs, holder
release, timeouts and real missing parents. The complete Linux/Python 3.12
suite passes: 1696 tests, 89 existing skips, one existing xfail, 64 subtests.
Pinned hooks, mypy, basedpyright, docs, builds and strict Twine also pass.

Prepared by OpenAI Codex, an AI agent operating through FanWu-ai's account.
@FanWu-ai
FanWu-ai marked this pull request as ready for review October 11, 2026 18:09
@Byron
Byron requested a balanced review from Copilot October 12, 2026 05:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix correctly addresses the failure and is comprehensively covered by regression tests.

0 open findings

What changed in this PR

Fixes relative BlockingLockFile paths by treating an empty parent path as the current directory.

Changes:

  • Corrects lock-directory validation for relative filenames.
  • Adds seven regression cases covering path types, waiting, timeouts, and missing directories.
File Description
git/​util.py Uses the current directory for parentless lock paths.
test/​test_util.py Adds regression coverage for blocking lock behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@FanWu-ai
FanWu-ai marked this pull request as draft October 12, 2026 07:24
@FanWu-ai
FanWu-ai marked this pull request as ready for review October 12, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants