object not found
when trying to pull a repository cloned with Depth: 1
#305
Closed
Description
Hi,
When you clone a repository with Depth: 1
, you cannot pull it. It'll error with object not found
.
Cloning:
_, err := git.PlainClone(repoPath, false, &git.CloneOptions{
URL: gitURL,
Depth: 1,
})
Pulling:
// Open repo
r, err := git.PlainOpen(repo.Path)
if err != nil {
panic(fmt.Errorf("error while opening git repo (%s) %s", repo.Name, err))
}
// Get worktree
tree, err := r.Worktree()
if err != nil {
panic(fmt.Errorf("error while opening git repo (%s) %s", repo.Name, err))
}
// Pull
err = tree.Pull(&git.PullOptions{})
// If repo is already up to date, do nothing
if err == git.NoErrAlreadyUpToDate {
// do nothing
} else if err != nil {
panic(fmt.Errorf("error while pulling git repo (%s) %s", repo.Name, err))
}
It's critical that I can pull with Depth: 1, because the repository I'm pulling might be very large (hundreds of thousands of commits). Can somebody take a look at this?