Skip to content

Fail to open repository with negative fetch spec #1927

@pjbgf

Description

@pjbgf

Bug Description

go-git is unable the open a repository with negative fetch spec due to strict validation, resulting in failed to open repository: read config: malformed refspec, separators are wrong

To fix this we need to:

  • Loose the existing validation to support negative ref specs.
  • Amend the Fetch logic so that it can support fetch wildcard refspec, after removing the negative ones.

Relates to entireio/cli#778.
Upstream information on negative refspec: https://git-scm.com/docs/git-fetch/2.31.0#Documentation/git-fetch.txt-refspec.

go-git Version

v6@main

Steps to Reproduce

The repository config:

  [core]
        repositoryformatversion = 1
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
  [remote "origin"]
        url = git@github.com:example/example.git
        promisor = true
        partialclonefilter = blob:none
        fetch = +refs/heads/*:refs/remotes/origin/*
        fetch = ^refs/heads/some-excluded-branch # <== The offending negation pattern!
        fetch = ^refs/heads/another-excluded-branch # <== (again)
  [branch "main"]
        remote = origin
        merge = refs/heads/main

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions