8000 Bug: worktree cannot be read if created with version 4 · Issue #1123 · go-git/go-git · GitHub
[go: up one dir, main page]

Skip to content
Bug: worktree cannot be read if created with version 4 #1123
@apodznoev

Description

@apodznoev

Steps to reproduce:

  • Setup git config file to contain a feature requiring index.version = 4, e.g.
[feature]
	manyFiles = true
  • Checkout a branch, call git status which creates index according to settings
  • Using gitGo create repository using the path above:
repo, _ := goGit.PlainOpen(repoPath)
  • Get a worktree status:
worktree, _ := repo.Worktree()
worktreeStatus, err := worktree.Status()

err is plumbing.format.index.ErrInvalidChecksum

My clue is that the index file has version 4 encoded in its header as of documentation https://git-scm.com/docs/gitformat-index

Where the library hardcodes version 2 and uses it for decoding index:

from: storage.filesystem.index.decoder.go

func (s *IndexStorage) Index() (i *index.Index, err error) {
	idx := &index.Index{
		Version: 2,
	}

	f, err := s.dir.Index()
	if err != nil {
		if os.IsNotExist(err) {
			return idx, nil
		}

		return nil, err
	}

	defer ioutil.CheckClose(f, &err)

	d := index.NewDecoder(f)
	err = d.Decode(idx)
	return idx, err
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0