summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-24 16:21:53 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-25 10:44:21 -0700
commita2c638f63fd94861e60d8dfdad517e6e14785d9f (patch)
tree20039d97108488d4ddb94c99d1d7772a04de3bcd
parent9f5a944107b7a8852adccd6da71dc94baa374bb5 (diff)
downloadsubsurface-a2c638f63fd94861e60d8dfdad517e6e14785d9f.tar.gz
Cloud storage: attempt to deal with conflicts about deleted files
This doesn't seem right, but it works. Definitely needs more analysis. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--git-access.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/git-access.c b/git-access.c
index 9c5b703a2..388fa27e2 100644
--- a/git-access.c
+++ b/git-access.c
@@ -222,12 +222,23 @@ static int try_to_git_merge(git_repository *repo, git_reference *local, git_refe
while (git_index_conflict_next(&ancestor, &ours, &theirs, iter)
!= GIT_ITEROVER) {
/* Mark this conflict as resolved */
- fprintf(stderr, "conflict in %s / %s / %s\n",
+ fprintf(stderr, "conflict in %s / %s / %s -- ",
ours ? ours->path : "-",
theirs ? theirs->path : "-",
ancestor ? ancestor->path : "-");
- error = git_index_conflict_remove(merged_index, ours->path);
+ if ((!ours && theirs && ancestor) ||
+ (ours && !theirs && ancestor)) {
+ // the file was removed on one side or the other - just remove it
+ fprintf(stderr, "looks like a delete on one side; removing the file from the index\n");
+ error = git_index_remove(merged_index, ours ? ours->path : theirs->path, GIT_INDEX_STAGE_ANY);
+ } else {
+ error = git_index_conflict_remove(merged_index, ours ? ours->path : theirs ? theirs->path : ancestor->path);
+ }
+ if (error) {
+ fprintf(stderr, "error at conflict resplution (%s)", giterr_last()->message);
+ }
}
+ git_index_conflict_cleanup(merged_index);
git_index_conflict_iterator_free(iter);
report_error(translate("gettextFromC", "Remote storage and local data diverged. Error: merge conflict - manual intervention needed"));
}