cLib: gitPull: Use the correct annoated_commit

The annotated commit must be created from the remote's branch's ref.
This entire thing is quite confusing, but for now at least git pull's
work properly, though with an extra merge commit.
This commit is contained in:
Vishesh Handa
2019-05-16 12:14:03 +02:00
parent 18a44d257b
commit 8b1cafef2f

View File

@ -474,11 +474,8 @@ int gj_git_pull(const char *git_base_path, const char *author_name, const char *
if (err < 0) if (err < 0)
goto cleanup; goto cleanup;
git_merge_options merge_options = GIT_MERGE_OPTIONS_INIT; // FIXME: Do not hardcode the master branch!
git_checkout_options checkout_options = GIT_CHECKOUT_OPTIONS_INIT; err = git_reference_lookup(&ref, repo, "refs/remotes/origin/master");
// FIXME: Maybe I should be taking the head of the remote?
err = git_repository_head(&ref, repo);
if (err < 0) if (err < 0)
goto cleanup; goto cleanup;
@ -486,6 +483,9 @@ int gj_git_pull(const char *git_base_path, const char *author_name, const char *
if (err < 0) if (err < 0)
goto cleanup; goto cleanup;
git_merge_options merge_options = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
err = git_merge(repo, (const git_annotated_commit **)&annotated_commit, 1, err = git_merge(repo, (const git_annotated_commit **)&annotated_commit, 1,
&merge_options, &checkout_options); &merge_options, &checkout_options);
if (err < 0) if (err < 0)
@ -552,9 +552,6 @@ int gj_git_pull(const char *git_base_path, const char *author_name, const char *
if (err < 0) if (err < 0)
goto cleanup; goto cleanup;
printf("Looked up origin head commit\n");
printf("About to commit\n");
const git_commit *parents[] = {head_commit, origin_head_commit}; const git_commit *parents[] = {head_commit, origin_head_commit};
char *message = "Custom Merge commit"; char *message = "Custom Merge commit";
git_oid commit_id; git_oid commit_id;