diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-08-22 16:19:17 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-22 17:52:31 -0700 |
commit | b8575221b19bf0a77319318a505a27c00e33e375 (patch) | |
tree | bab508e90ab88546f230bf53f9c98c1d3a2ae46a /git-access.c | |
parent | fe0864be601064e1662802eb520f6c5e61f6a87c (diff) | |
download | subsurface-b8575221b19bf0a77319318a505a27c00e33e375.tar.gz |
Cloud storage: use merge options to avoid conflicts
In many cases Subsurface will do something "reasonable" if we have
conflicting edits and then try to merge. GIT_MERGE_FILE_FAVOR_UNION means
that both edits will be added to the final file and then Subsurface should
quietly take one or the other - this will need quite a bit of testing.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'git-access.c')
-rw-r--r-- | git-access.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/git-access.c b/git-access.c index ff00b85a3..3602b80f0 100644 --- a/git-access.c +++ b/git-access.c @@ -218,6 +218,10 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference git_tree *local_tree, *remote_tree, *base_tree; git_commit *local_commit, *remote_commit, *base_commit; git_index *merged_index; + git_merge_options merge_options; + git_merge_init_options(&merge_options, GIT_MERGE_OPTIONS_VERSION); + merge_options.tree_flags = GIT_MERGE_TREE_FIND_RENAMES; + merge_options.file_favor = GIT_MERGE_FILE_FAVOR_UNION; if (git_commit_lookup(&local_commit, repo, local_id)) return report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: can't get commit (%s)"), giterr_last()->message); if (git_commit_tree(&local_tree, local_commit)) @@ -230,7 +234,7 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference return report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: can't get commit: (%s)"), giterr_last()->message); if (git_commit_tree(&base_tree, base_commit)) return report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: failed base tree lookup: (%s)"), giterr_last()->message); - if (git_merge_trees(&merged_index, repo, base_tree, local_tree, remote_tree, 0)) + if (git_merge_trees(&merged_index, repo, base_tree, local_tree, remote_tree, &merge_options)) return report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: merge failed (%s)"), giterr_last()->message); if (git_index_has_conflicts(merged_index)) { return report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: merge conflict - manual intervention needed")); |