summaryrefslogtreecommitdiffstats
path: root/core/git-access.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/git-access.c')
-rw-r--r--core/git-access.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/core/git-access.c b/core/git-access.c
index 3688cb90c..961c9b271 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -349,6 +349,7 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
git_commit *local_commit, *remote_commit, *base_commit;
git_index *merged_index;
git_merge_options merge_options;
+ struct membuffer msg = { 0, 0, NULL};
if (verbose) {
char outlocal[41], outremote[41];
@@ -359,11 +360,7 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
}
git_merge_init_options(&merge_options, GIT_MERGE_OPTIONS_VERSION);
-#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR > 23
merge_options.flags = GIT_MERGE_FIND_RENAMES;
-#else
- merge_options.tree_flags = GIT_MERGE_TREE_FIND_RENAMES;
-#endif
merge_options.file_favor = GIT_MERGE_FILE_FAVOR_UNION;
merge_options.rename_threshold = 100;
if (git_commit_lookup(&local_commit, repo, local_id)) {
@@ -434,10 +431,12 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
goto write_error;
if (git_tree_lookup(&merged_tree, repo, &merge_oid))
goto write_error;
- if (git_signature_default(&author, repo) < 0)
- if (git_signature_now(&author, "Subsurface", "noemail@given") < 0)
- goto write_error;
- if (git_commit_create_v(&commit_oid, repo, NULL, author, author, NULL, "automatic merge", merged_tree, 2, local_commit, remote_commit))
+ if (get_authorship(repo, &author) < 0)
+ goto write_error;
+ const char *user_agent = subsurface_user_agent();
+ put_format(&msg, "Automatic merge\n\nCreated by %s\n", user_agent);
+ free((void *)user_agent);
+ if (git_commit_create_v(&commit_oid, repo, NULL, author, author, NULL, mb_cstring(&msg), merged_tree, 2, local_commit, remote_commit))
goto write_error;
if (git_commit_lookup(&commit, repo, &commit_oid))
goto write_error;
@@ -454,12 +453,14 @@ static int try_to_git_merge(git_repository *repo, git_reference **local_p, git_r
git_signature_free(author);
if (verbose)
fprintf(stderr, "Successfully merged repositories");
+ free_buffer(&msg);
return 0;
diverged_error:
return report_error(translate("gettextFromC", "Remote storage and local data diverged"));
write_error:
+ free_buffer(&msg);
return report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: writing the data failed (%s)"), giterr_last()->message);
}