Skip to content

invalid tree object can be produced #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MichaelMure opened this issue Oct 24, 2020 · 4 comments
Closed

invalid tree object can be produced #193

MichaelMure opened this issue Oct 24, 2020 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@MichaelMure
Copy link
Contributor

Found that out after running git fsck on a repo where I've been using go-git (through git-bug):

$ git fsck
erreur dans l'objet tree ac67188617b481887f55414af55b02631deaf5b9 : treeNotSorted: not properly sorted

Turns out that tree entries need to be sorted when serialized. Beware thought, it's a slightly peculiar order: isomorphic-git/isomorphic-git#937

I would assume that it would be go-git's reponsibility to ensure valid stored data.

@itsanpach
Copy link

Hey, it's Ann! I'm having problems keeping new emails now. Please
Note, I am prioritizing time the best I can on a phone. Thanks beyond words for the help.

@MichaelMure
Copy link
Contributor Author

FYI, this is what I used as a workaround. It uses my own struct instead of object.TreeEntry but you should get the idea.

sort.Slice(sorted, func(i, j int) bool {
	nameI := sorted[i].Name
	if sorted[i].ObjectType == Tree {
		nameI += "/"
	}
	nameJ := sorted[j].Name
	if sorted[j].ObjectType == Tree {
		nameJ += "/"
	}
	return nameI < nameJ
})

Copy link

To help us keep things tidy and focus on the active tasks, we've introduced a stale bot to spot issues/PRs that haven't had any activity in a while.

This particular issue hasn't had any updates or activity in the past 90 days, so it's been labeled as 'stale'. If it remains inactive for the next 30 days, it'll be automatically closed.

We understand everyone's busy, but if this issue is still important to you, please feel free to add a comment or make an update to keep it active.

Thanks for your understanding and cooperation!

@github-actions github-actions bot added the stale Issues/PRs that are marked for closure due to inactivity label Dec 14, 2023
@pjbgf pjbgf added bug Something isn't working help wanted Extra attention is needed and removed stale Issues/PRs that are marked for closure due to inactivity labels Dec 14, 2023
@pjbgf
Copy link
Member

pjbgf commented Mar 9, 2024

Fixed by #967.

@pjbgf pjbgf closed this as completed Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants