go-git icon indicating copy to clipboard operation
go-git copied to clipboard

Pull: object not found

Open cmbernard333 opened this issue 5 years ago • 3 comments

I am seeing this issue with v4.11.0. Clone is done like this

r, err := git.PlainClone(path, false, &git.CloneOptions{
	Auth:          authmethod,
	ReferenceName: plumbing.NewBranchReferenceName(branchName),
	Depth:         depth,
	SingleBranch:  singleBranchOnly,
	URL:           gitURL,
})

Followed by a pull later on

w, err := g.Repository.Worktree()
if err != nil {
	return err
}
return w.Pull(&git.PullOptions{
	Auth:         authMethod,
	Depth:        depth,
	RemoteName:   "origin",
	SingleBranch: singleBranch})

Depth is set to 1 to do a shallow clone.

Results in this error Could not pull github.com:PatchSimple/ax-recipes.git. Err: object not found

Is this still an issue in the latest code?

cmbernard333 avatar May 03 '19 14:05 cmbernard333

The strange thing is it looks like the repo is now up-to-date

# git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

cmbernard333 avatar May 03 '19 15:05 cmbernard333

Is this not being addressed? Updating a shallow clone is a pretty useful feature.

cmbernard333 avatar May 08 '19 17:05 cmbernard333

I have version v4.13.1 and confirm the same behavior. If I remove the depth option then it works fine

// Clone & forget _, err := git.PlainClone(directory, false, &git.CloneOptions{ URL: g.URL, ReferenceName: g.Branch, SingleBranch: true, Auth: &http.BasicAuth{ Username: g.Gituser, Password: g.Gittoken, }, // Unable to use this option due to: //Depth: 2, })

and pull

err = w.Pull(&git.PullOptions{ RemoteName: "origin", // ReferenceName: g.Branch, // SingleBranch: true, Auth: &http.BasicAuth{ Username: g.Gituser, Password: g.Gittoken, }, // Depth: 2, })

Works fine.

liafizan avatar Sep 09 '19 21:09 liafizan