Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shallow clone fails on merge commits #965

Open
Pan-Maciek opened this issue Dec 12, 2023 · 0 comments
Open

Shallow clone fails on merge commits #965

Pan-Maciek opened this issue Dec 12, 2023 · 0 comments

Comments

@Pan-Maciek
Copy link

How to reproduce the issue:

  1. Create a merge request based on main branch with one commit or more
  2. Do at least one commit to main
  3. Clone repo with depth 1 and single branch main
repo, err := git.PlainClone(RepositoryPath, false, &git.CloneOptions{
  URL:           url,
  SingleBranch:  true,
  Tags:          git.NoTags,
  ReferenceName: "main",
  Depth:         1,
})
  1. Fetch changes
err := repo.Fetch(&git.FetchOptions{
  Tags:     git.NoTags,
  Force:    true,
})

What happens

  • git merge commit contains two parents
  • second parent has history older than grafted commit so at some point when traversing commits you get object that don't exist

How git cli solves this issue?

First commit that is unrechable from second parent points to grafted commit. At lest that's what I would assume from reproducing this scenario with git cli client.

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

No branches or pull requests

1 participant