Skip to content

FugitiveHead() produces wrong value with reftable #2371

@bk2204

Description

@bk2204

Git has a new ref backend called reftable. When that's used, the ref data and reflogs are stored inside a set of binary files and the .git/HEAD file always contains ref: refs/heads/.invalid (note that .invalid is not permitted in a real refname).

As a result, calling FugitiveHead returns .invalid, which is not correct. This also causes Airline to reflect the incorrect branch name.

To reproduce this situation, you can set up a repository with Git 2.48 and this shell script:

#!/bin/sh

git init -b dev --ref-format=reftable test-repo
cd test-repo
touch abc.txt
git add abc.txt
git commit -m +

Once inside, you can open Vim with Fugitive enabled and run :call FugitiveHead(). The correct result is dev, and the incorrect result is .invalid.

I suspect you are going to need to actually invoke Git in this case. Perhaps a command like git rev-parse --abbrev-ref HEAD will be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions