Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Fetch: object not found #802

Closed
jacksgt opened this issue Apr 9, 2018 · 9 comments
Closed

Fetch: object not found #802

jacksgt opened this issue Apr 9, 2018 · 9 comments
Assignees
Labels

Comments

@jacksgt
Copy link

jacksgt commented Apr 9, 2018

Hi there,

I'm having an issue fetching updates from Github.

The repository was previously cloned like so:

	r, err := git.PlainClone(dir, false, &git.CloneOptions{
		URL:   url,
		Depth: 1,
	})

then, after modifications have been made to the remote repository, I want to fetch updates:

	err = r.Fetch(&git.FetchOptions{})

But this results in a object not found error (ErrObjNotFound).

git fetch (--all) works just fine.

Any suggestions how I can debug this issue?

@mcuadros
Copy link
Contributor

Can you provide a repository where this fails? Thanks

@jacksgt
Copy link
Author

jacksgt commented Apr 10, 2018

@barnettZQG
Copy link

same issues.
clone single branch.
Clone config:

opts := &git.CloneOptions{
		URL:               csi.RepositoryURL,
		Progress:          progress,
		SingleBranch:      true,
		RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
		Depth:             1,
	}

if I commit 2 times or more. pull will result ErrObjNotFound

opts := &git.PullOptions{
		Progress:     progress,
		SingleBranch: true,
}

@barnettZQG
Copy link

There's how I analyzed it.

Becaues clone options set depth is 1. after clone, local store have one commit info that it have parent commit hash, but local store don't have parent commit info.
gopkg.in/src-d/go-git.v4/plumbing/storer/object.go

func (iter *EncodedObjectLookupIter) Next() (plumbing.EncodedObject, error) {
	fmt.Println("(iter *EncodedObjectLookupIter) Next()", len(iter.series))
	if iter.pos >= len(iter.series) {
		return nil, io.EOF
	}

	hash := iter.series[iter.pos]
	fmt.Println("(iter *EncodedObjectLookupIter) Hash", hash)
	obj, err := iter.storage.EncodedObject(iter.t, hash)
	if err == nil {
		iter.pos++
	}
	return obj, err
}
# output
# (iter *EncodedObjectLookupIter) Next() 1
# (iter *EncodedObjectLookupIter) Hash 00135cb9d1a16fe910404efa7024c8e7f67851f7
# iter.EncodedObjectIter.Next() object not found

when pull code, it could loop local store commits. Error in the appeal code. then why need to loop local store commits or whether need to ignore this error in the pull.

@jacksgt
Copy link
Author

jacksgt commented Apr 12, 2018

So this only happens when the initial clone was done with depth = 1?

@barnettZQG
Copy link

@jacksgt I think so

@jfontan
Copy link
Contributor

jfontan commented Apr 16, 2018

Can you check if #810 fixes your problems?

@mcuadros mcuadros added the bug label Apr 17, 2018
@mcuadros
Copy link
Contributor

@jacksgt can you check if is now fixed at version: v4.3.1?
https://github.com/src-d/go-git/releases/tag/v4.3.1

@mcuadros
Copy link
Contributor

Closing, if it isn't fixed please re-open

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants