Visitar URL original
`active_branch` is detected incorrectly when using `reftable` · Issue #2113 · gitpython-developers/GitPython · GitHub
Skip to content

active_branch is detected incorrectly when using reftable #2113

Description

@alynn-coefficient

On git repositories using the new reftable format (slated to become the default in the upcoming Git 3.0.0), GitPython detects the wrong ref as being active.

Observe, with the traditional "files" format:

mkdir test
cd test
git init --ref-format=files
uvx --with gitpython python -c "import git; print(git.Repo('.').active_branch.name)"

Produces main as expected. However:

mkdir test
cd test
git init --ref-format=reftable
uvx --with gitpython python -c "import git; print(git.Repo('.').active_branch.name)"

Produces .invalid.

Activity

  1. Byron commented on Mar 19, 2026

    @Byron
    Member

    While the object database with SHA256 should be fine, the reference handling will have a problem as it's currently done in pure python.

    To support this properly, I think it would have to detect reftables and switch to an alternative implementation, probably one that just uses Git under the hood.

  2. alynn-coefficient commented on Mar 20, 2026

    @alynn-coefficient
    Author

    Is there a shorter-term option perhaps to add the detection and just error loudly? I realise that full native reftables support may be a longer-term project.

  3. planetmarshall commented on Apr 1, 2026

    @planetmarshall

    On git repositories using the new reftable format (slated to become the default in the upcoming Git 3.0.0)...

    Also worth noting that reftables may already be widely used on macos where a case-insensitive filesystem is the default - due to git suggesting that users migrate if it detects a case-sensitivity conflict:

    error: You're on a case-insensitive filesystem, and the remote you are
    trying to fetch from has references that only differ in casing. It
    is impossible to store such references with the 'files' backend. You
    can either accept this as-is, in which case you won't be able to
    store all remote references on disk. Or you can alternatively
    migrate your repository to use the 'reftable' backend with the
    following command:
    
        git refs migrate --ref-format=reftable
    
    Please keep in mind that not all implementations of Git support this
    new format yet. So if you use tools other than Git to access this
    repository it may not be an option to migrate to reftables.
    

    Was caught by this recently when using repo.index.diff("HEAD") to detect a changeset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions