Commit e8d373c4 by Etiene Dalcol

merge: add error handling for index reload

Cleans up should git_repository_index or git_index_read fail
parent 5248a1a5
......@@ -3239,9 +3239,6 @@ int git_merge(
assert(repo && their_heads);
git_repository_index(&index, repo);
git_index_read(index, 0);
if (their_heads_len != 1) {
giterr_set(GITERR_MERGE, "can only merge a single branch");
return -1;
......@@ -3258,6 +3255,10 @@ int git_merge(
&checkout_strategy)) < 0)
goto done;
if ((error = git_repository_index(&index, repo) < 0) ||
(error = git_index_read(index, 0) < 0))
goto done;
/* Write the merge setup files to the repository. */
if ((error = git_annotated_commit_from_head(&our_head, repo)) < 0 ||
(error = git_merge__setup(repo, our_head, their_heads,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment