summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/git-access.c13
-rw-r--r--core/git-access.h1
-rw-r--r--core/save-git.c2
3 files changed, 11 insertions, 5 deletions
diff --git a/core/git-access.c b/core/git-access.c
index 982a51cfd..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];
@@ -430,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;
@@ -450,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);
}
diff --git a/core/git-access.h b/core/git-access.h
index 19cdde46a..8e20395a4 100644
--- a/core/git-access.h
+++ b/core/git-access.h
@@ -31,6 +31,7 @@ void set_git_update_cb(int(*)(const char *));
int git_storage_update_progress(const char *text);
char *get_local_dir(const char *remote, const char *branch);
int git_create_local_repo(const char *filename);
+int get_authorship(git_repository *repo, git_signature **authorp);
#ifdef __cplusplus
}
diff --git a/core/save-git.c b/core/save-git.c
index e3564eea7..aaf8d5742 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -1020,7 +1020,7 @@ int update_git_checkout(git_repository *repo, git_object *parent, git_tree *tree
return git_checkout_tree(repo, (git_object *) tree, &opts);
}
-static int get_authorship(git_repository *repo, git_signature **authorp)
+int get_authorship(git_repository *repo, git_signature **authorp)
{
if (git_signature_default(authorp, repo) == 0)
return 0;