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

kart merge doesn't work with shallow clones #555

Closed
olsen232 opened this issue Feb 16, 2022 · 2 comments · Fixed by #556
Closed

kart merge doesn't work with shallow clones #555

olsen232 opened this issue Feb 16, 2022 · 2 comments · Fixed by #556

Comments

@olsen232
Copy link
Collaborator

Trying to merge two commits that share an ancestor, and that ancestor has a parent, and that parent is missing due to being a shallow clone, fails with the following error:

  ...
  File "kart/merge.py", line 313, in merge
  File "kart/merge.py", line 57, in do_merge
_pygit2.GitError: object not found - no match for id (e9cdf8481b46172e8cb21b0696747f9672eef66e)

It's not clear why this wouldn't work - I'll do some digging. It fails within libgit2 function git_merge_trees somewhere.

There is no issue with merging in a shallow clone as long as both the ancestor and the ancestor's parent are both present. So, this can be avoided by doing a clone one deeper than you think you need - if you think you need a clone with depth=1, clone it with depth=2 so that you have one more parent and everything will work fine.

There may also be an issue where merges fail if the ancestor itself is missing due to shallow-clone - this is more understandable / unavoidable however, since, without the merge-ancestor, we don't know how each branch has changed, so we don't really know what we are merging. In this case, the fix would be to deepen the clone at least as far as the merge ancestor before performing the merge.

This was found as part of spatial filtering testing but is not actually related to spatial filtering and is not a regression - all versions of Kart have this issue.

@olsen232
Copy link
Collaborator Author

Correction - this fails within libgit2 function git_merge_base

@olsen232
Copy link
Collaborator Author

Related - libgit2 shallow-clones tracking issue libgit2/libgit2#3058

olsen232 added a commit that referenced this issue Feb 17, 2022
libgit2 doesn't support shallow clones, and so operations that involve
walking back through the commits like `git_merge_base` can fail
(depending on the exact circumstances).
This workaround simply switches to using `git merge-base` instead - the
same functionality, but from within git, which does support shallow clones.

Adds a test case to show it is fixed.
olsen232 added a commit that referenced this issue Feb 17, 2022
libgit2 doesn't support shallow clones, and so operations that involve
walking back through the commits like `git_merge_base` can fail
(depending on the exact circumstances).
This workaround simply switches to using `git merge-base` instead - the
same functionality, but from within git, which does support shallow clones.

Adds a test case to show it is fixed.
olsen232 added a commit that referenced this issue Feb 17, 2022
Fix for #555 - issues with merge + shallow clones
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

Successfully merging a pull request may close this issue.

1 participant