diff options
-rw-r--r-- | git-access.c | 13 | ||||
-rw-r--r-- | save-git.c | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/git-access.c b/git-access.c index 07eb76a68..2b44cb6b3 100644 --- a/git-access.c +++ b/git-access.c @@ -217,6 +217,19 @@ static int try_to_git_merge(git_repository *repo, git_reference *local, git_refe return report_error(translate("gettextFromC", "Failed to get author: (%s)"), giterr_last()->message); if (git_commit_create_v(&commit_oid, repo, "HEAD", author, author, NULL, "automatic merge", merged_tree, 2, local_commit, remote_commit)) return report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: git commit create failed (%s)"), giterr_last()->message); + if (git_commit_lookup(&commit, repo, &commit_oid)) + return report_error(translate("gettextFromC", "Error: could not lookup the merge commit I just created (%s)"), giterr_last()->message); + if (git_branch_is_head(local) && !git_repository_is_bare(repo)) { + git_object *parent; + git_reference_peel(&parent, local, GIT_OBJ_COMMIT); + if (update_git_checkout(repo, parent, merged_tree)) { + report_error("Warning: checked out branch is inconsistent with git data"); + } + } + if (git_reference_set_target(&local, local, &commit_oid, "Subsurface merge event")) + return report_error("Error: failed to update branch (%s)", giterr_last()->message); + set_git_id(&commit_oid); + git_signature_free(author); } return 0; } diff --git a/save-git.c b/save-git.c index 9ae1d572e..3cd8a8a2c 100644 --- a/save-git.c +++ b/save-git.c @@ -997,7 +997,7 @@ static git_tree *get_git_tree(git_repository *repo, git_object *parent) return tree; } -static int update_git_checkout(git_repository *repo, git_object *parent, git_tree *tree) +int update_git_checkout(git_repository *repo, git_object *parent, git_tree *tree) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; |