libgit2 / libgit2/rugged

Index resulting from repo.merge_commits() is owned by the repo, unsavable

Open
#466 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
C
Stars
2.3k
Forks
293
PR merge metrics
No merged PRs in 30d

Description

Given a merge index with conflicts, when trying to save it to the current index the operation fails with a runtime error:
"the given object is already owned by another repository (RuntimeError)"

The use case here is to implement a workflow similar to git-merge. We try to perform a merge and if it fails we write the result of the merge into the current index and pass control back to the user to resolve conflicts. This fails and merge_index is essentially impossible to write to disk (until the conflicts are resolved).

require 'rugged'
repo = Rugged::Repository.new("/source/test")
merge_index = repo.merge_commits(repo.branches['child'].target, repo.branches['master'].target)
if (merge_index.conflicts?)
   repo.index = merge_index  #fails 
   merge_index.write()
end

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the conflict case through repo.merge_commits(...), then inspect the ownership path used by repo.index= and merge_index.write(). Confirm the fix by verifying that a conflicted merge index can be assigned to the repository's current index and written to disk without the ownership RuntimeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, git, ruby
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.