Skip to content

Git repositories using SHA256 object format break helix_vcs features #12116

@bvergnaud

Description

@bvergnaud

Summary

In a git repository that uses SHA256 object format, the gutter in helix does not indicate additions/changes/deletions as it normally does, and resetting diff patches does not work with helix indicating that Diff is not available in the buffer.

It seems that gix does not support SHA256 yet which is the most likely explanation of the problem. It causes a similar issue in starship where the prompt does not show the git related informations. It also means that there might be other problems in such repositories that I haven't yet noticed. I don't have an exhaustive view of all the ways helix relies on git, but at least ignored files are still ignored properly.

Possible solutions would be:

  • Wait for gix to implement support for SHA256 object format. There's an issue for it, but no timeline.
  • Switch to a different implementation. git2 is not there yet either, I don't know if there are other solid git crates.
  • Use custom code / build a new git library. Seems overkill but it's possible nonetheless. :D

Reproduction Steps

A simple way to replicate the issue:

for obj_format in sha1 sha256 ; do
  git init --object-format=sha1 "test-${obj_format}"
  printf "this\nis\na\ntest\n" > "test-${obj_format}/file.txt"
  git -C "test-${obj_format}/" add file.txt
  git -C "test-${obj_format}/" commit -m "initial commit"
done

Then compare editing file.txt in each test repository by adding / changing / removing lines and see that the gutter shows nothing in the test-sha256 repository.

Helix log

2024-11-23T19:29:42.333 helix_vcs [DEBUG] Error {
    context: "failed to open git repo",
    source: Open(
        Config(
            ConfigTypedString(
                Error {
                    key: "extensions.objectFormat",
                    value: Some(
                        "sha256",
                    ),
                    environment_override: None,
                    source: None,
                },
            ),
        ),
    ),
}
2024-11-23T19:29:42.333 helix_vcs [DEBUG] failed to open diff base for /home/bvergnaud/Downloads/helix-git-gutter-bug-demo/test-sha256/file.txt
2024-11-23T19:29:42.333 helix_vcs [DEBUG] Error {
    context: "failed to open git repo",
    source: Open(
        Config(
            ConfigTypedString(
                Error {
                    key: "extensions.objectFormat",
                    value: Some(
                        "sha256",
                    ),
                    environment_override: None,
                    source: None,
                },
            ),
        ),
    ),
}
2024-11-23T19:29:42.333 helix_vcs [DEBUG] failed to obtain current head name for /home/bvergnaud/Downloads/helix-git-gutter-bug-demo/test-sha256/file.txt

Platform

Linux

Terminal Emulator

kitty

Installation Method

Official extra/helix package in arch linux repositories

Helix Version

helix 24.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions