Skip to content

Commit

Permalink
Ensure the index owner is set.
Browse files Browse the repository at this point in the history
The index returned by `git_merge_trees` should be owned by the
repository. Otherwise things like `git_diff_index_to_workdir` will
crash when trying to generate a diff with the returned index.
  • Loading branch information
arthurschreiber committed Jun 2, 2015
1 parent 5b6292a commit 0982908
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/merge.c
Expand Up @@ -1805,6 +1805,7 @@ int git_merge_trees(
git__free(opts.metric);

error = index_from_diff_list(out, diff_list);
GIT_REFCOUNT_OWN(*out, repo);

done:
git_merge_diff_list__free(diff_list);
Expand Down
1 change: 1 addition & 0 deletions tests/merge/trees/trivial.c
Expand Up @@ -50,6 +50,7 @@ static int merge_trivial(git_index **index, const char *ours, const char *theirs
cl_git_pass(git_commit_tree(&their_tree, their_commit));

cl_git_pass(git_merge_trees(index, repo, ancestor_tree, our_tree, their_tree, &opts));
cl_assert(git_index_owner(index) == repo);

git_buf_free(&branch_buf);
git_tree_free(our_tree);
Expand Down

0 comments on commit 0982908

Please sign in to comment.