go-git
go-git copied to clipboard
Pull: object not found
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?
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
Is this not being addressed? Updating a shallow clone is a pretty useful feature.
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.