diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-04-09 17:05:55 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-04-10 09:53:24 -0700 |
commit | 53fb533a99eef94d5df1a5258bc23ec123f59d6d (patch) | |
tree | ebf363d619f3f27bc90b8d9fd2b06fea8593c53e /core/git-access.c | |
parent | 7a238b614685ce7d85b1a7564871e72c960bad89 (diff) | |
download | subsurface-53fb533a99eef94d5df1a5258bc23ec123f59d6d.tar.gz |
cloud-storage: create consistent commit message for merges
This never made sense and I think I just forgot to complete this code
when I first worked on it. Now we can see which version of Subsurface or
Subsurface-mobile created a merge.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/git-access.c')
-rw-r--r-- | core/git-access.c | 13 |
1 files changed, 9 insertions, 4 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); } |