FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(odb): restore the legacy `GitDB` backend selector · gitpython-developers/GitPython@f38240f · GitHub

Repository navigation

Commit f38240f

Browse files
authored andcommitted
fix(odb): restore the legacy GitDB backend selector
Aider-chat 0.86.2 opens every repository with `Repo(..., odbt=git.GitDB)`. Removing that public name blocks all 21 unchanged upstream repository tests with `AttributeError`, before diffs, commits, attribution or tracked-file queries can run. The same full selection passes with released GitPython 3.2.1. Aider uses the name only as a constructor selector and does not rely on gitdb's Python storage implementation or specialized object-database methods. Export `GitDB` from `git` and `git.db` as an alias for `GitCmdObjectDB`. Legacy selectors now choose the same managed Git/Gix backend as the default, without restoring independent Python object storage, widening accepted custom backend types, or changing native/fallback decisions. Document that the selector survives while the old implementation's specialized interfaces remain unsupported. Add a regression across SHA-1/SHA-256 and files/reftable storage that verifies both exports, repository construction and actual managed object header/stream queries. All four cases fail before the alias. The regression plus adjacent repository and safety suites pass 173 tests, two skips and 14 subtests on each backend, CLI first. Aider's full 21-test repository suite now passes on both backends against the editable checkout. Ruff lint/format, mypy for changed production modules and `git diff --check` pass with Python 3.12.15, Git 2.53.0 and GixPython 0.2.0. The broader second downstream audit remains in progress.
1 parent fc4399d commit f38240f

5 files changed

Lines changed: 39 additions & 5 deletions

File tree

‎doc/gix-backend.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ fallbacks.
4545

4646
## Index and object metadata lifecycle
4747

48+
`git.GitDB` and `git.db.GitDB` remain compatibility aliases for
49+
`GitCmdObjectDB`, so legacy `Repo(..., odbt=GitDB)` selectors use the same
50+
managed backend. Aider 0.86.2 uses that selector for every repository open.
51+
This does not restore gitdb's Python object database or its specialized APIs.
52+
Object queries continue through `object_data()` and the supported
53+
`Repository.try_find_header()`/`find_object()` APIs, with the existing large-object
54+
and diagnostic CLI fallbacks. Storage uses the existing `hash_object` dispatch.
55+
4856
`IndexFile` queries immutable entry records; it does not retain a parsed index.
4957
The compatibility `entries` property projects those queries into a read-only
5058
snapshot keyed by path and stage, preserving readers in dlt and Renku. It uses

‎doc/source/changes.rst‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ API changes
5454
* ``GitCmdObjectDB`` no longer inherits ``LooseObjectDB``. Its object reads,
5555
writes, existence checks, and enumeration use Git, including packed objects.
5656
Precompressed input streams and custom object-output writers are unsupported.
57-
``GitDB`` exports and backend selection are removed. ``odbt`` accepts only
58-
``GitCmdObjectDB`` and its subclasses, rejecting unsupported types before
59-
initialization or cloning. Remove ``odbt=GitDB`` or select ``GitCmdObjectDB``.
57+
``GitDB`` remains exported as a compatibility alias for ``GitCmdObjectDB``;
58+
``odbt=GitDB`` selects the same managed Git/Gix backend. It no longer selects
59+
gitdb's Python storage implementation or supports that implementation's
60+
specialized interfaces. ``odbt`` accepts ``GitCmdObjectDB`` and its subclasses,
61+
rejecting unsupported types before initialization or cloning.
6062
``gitdb`` remains a dependency for shared types and utilities.
6163
* ``Repo.object_format`` and ``Repo.ref_format`` report Git's storage formats.
6264
``Repo.alternates`` is read-only and reports effective absolute alternate

‎git/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"GitCommandError",
3030
"GitCommandNotFound",
3131
"GitConfigParser",
32+
"GitDB",
3233
"GitError",
3334
"HEAD",
3435
"Head",
@@ -146,7 +147,7 @@
146147
DiffIndex,
147148
Diffable,
148149
)
149-
from git.db import GitCmdObjectDB # @NoMove
150+
from git.db import GitCmdObjectDB, GitDB # @NoMove
150151
from git.cmd import Git # @NoMove
151152
from git.repo import Repo # @NoMove
152153
from git.remote import FetchInfo, PushInfo, Remote, RemoteProgress # @NoMove

‎git/db.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"""Git's object database, accessed exclusively through the Git command."""
55

6-
__all__ = ["GitCmdObjectDB"]
6+
__all__ = ["GitCmdObjectDB", "GitDB"]
77

88
import tempfile
99
from typing import Iterator, TYPE_CHECKING
@@ -107,3 +107,8 @@ def partial_to_complete_sha_hex(self, partial_hexsha: str) -> bytes:
107107
return hex_to_bin(hexsha)
108108
except (GitCommandError, ValueError) as exc:
109109
raise BadObject(partial_hexsha) from exc
110+
111+
112+
# Preserve the public object-backend selector used by downstream applications.
113+
# Storage remains owned by Git/Gix; this does not restore gitdb's Python backend.
114+
GitDB = GitCmdObjectDB

‎test/test_downstream_compatibility.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,27 @@
44

55
import pytest
66

7+
import git
8+
import git.db
9+
710
from test.lib.fixtures import fixture_repo
811

912

13+
@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
14+
@pytest.mark.parametrize("ref_format", ["files", "reftable"])
15+
def test_legacy_gitdb_selector_uses_the_managed_object_backend(object_format, ref_format):
16+
assert git.GitDB is git.db.GitDB is git.GitCmdObjectDB
17+
with fixture_repo("downstream-index.sh", object_format, ref_format) as fixture:
18+
with git.Repo(fixture.working_tree_dir, odbt=git.GitDB) as repo:
19+
assert isinstance(repo.odb, git.GitCmdObjectDB)
20+
blob = repo.head.commit.tree["tracked"]
21+
assert repo.odb.has_object(blob.binsha)
22+
info = repo.odb.info(blob.binsha)
23+
assert info.binsha == blob.binsha
24+
assert info.type == b"blob"
25+
assert repo.odb.stream(blob.binsha).read() == blob.data_stream.read()
26+
27+
1028
@pytest.mark.parametrize("object_format", ["sha1", "sha256"])
1129
@pytest.mark.parametrize("ref_format", ["files", "reftable"])
1230
def test_index_entries_readers_retain_pending_and_published_snapshots(object_format, ref_format):

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL