Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

index: feature.manyFiles / feature.experimental not expanded, so index.skipHash is ignored (invalid checksum on read) #2196

Copy link
Copy link

Description

@awlx
Issue body actions

Bug Description

When a repository's .git/config enables index.skipHash indirectly via Git's
feature.manyFiles = true (or feature.experimental = true) meta-setting,
go-git fails to read the index with:

index decoder: invalid checksum

Git writes the index trailer as 20 (or 32 for SHA-256) zero bytes when
index.skipHash is in effect. go-git supports index.skipHash when the key is
present literally under [index], but it does not expand Git's
feature.* aliases, so Config.Index.SkipHash stays unset and the decoder
verifies the checksum against the all-zero trailer and rejects the index.

go-git Version

v6.0.0-alpha

Steps to Reproduce

git init repo && cd repo
git config feature.manyFiles true   # implies index.skipHash=true in Git >= 2.40
echo hi > a.txt && git add a.txt && git commit -m init
package main

import (
    "fmt"

    git "github.com/go-git/go-git/v6"
)

func main() {
    repo, err := git.PlainOpen("repo")
    if err != nil {
        panic(err)
    }
    wt, err := repo.Worktree()
    if err != nil {
        panic(err)
    }
    _, err = wt.Status()
    fmt.Println("status err:", err) // => index decoder: invalid checksum
}

git status on the same repo works fine. Adding git config index.skipHash true
explicitly also makes go-git succeed, confirming the gap is alias expansion, not
checksum handling.

Additional Information

Expected behavior

go-git should honor Git's feature.manyFiles / feature.experimental
meta-settings, which expand to (per Git docs):

  • feature.manyFiles=trueindex.skipHash=true, index.version=4, core.untrackedCache=true
  • feature.experimental=trueindex.skipHash=true (among others)

so that reading such an index does not error. At minimum, index.skipHash
should be inferred from feature.manyFiles / feature.experimental when the
literal index.skipHash key is absent.

Notes

  • feature.manyFiles is increasingly common: some Git GUIs/tooling and large
    monorepos enable it for performance.
  • A repo with this config also typically carries UNTR (untracked cache) and
    FSMN (fsmonitor) index extensions; those decode fine as optional extensions —
    the only failure is the zero-checksum verification.
  • Possibly related: Bug: worktree cannot be read if created with version 4 #1123 (index version 4 read failure).
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.