8000 config parsing fails with "Empty subsection name" · Issue #1197 · go-git/go-git · GitHub
[go: up one dir, main page]

Skip to content
config parsing fails with "Empty subsection name" #1197
Open
@srijan-paul

Description

@srijan-paul

If the .git/config file has an empty subsection name like this:

[remote ""]
url = "foo"
fetch = "bar"

The official git implementation works fine, but go-git fails to parse the config with an error that says "empty subsection name".
Found out while using go-git at work to analyze git repos.

I'd be happy to send a patch to make go-git behave the same as git.

Minimal reproduction:

package main

import "github.com/go-git/go-git/v5"

func must(err error) {
	if err != nil {
		panic(err)
	}
}

func main() {
       // somerepo/.git/config should have an empty toml subsection.
	repo, err := git.PlainOpen("./somerepo")
	must(err)

	remotes, err := repo.Remotes()
	must(err) // panics here

	for _, remote := range remotes {
		println(remote.Config().Name)
	}

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0