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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy