Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

object not found when trying to pull a repository cloned with Depth: 1 #305

Copy link
Copy link
Closed
@stingalleman

Description

@stingalleman
Issue body actions

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.