diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2015-05-14 11:52:48 -0400 |
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2015-05-28 09:43:49 -0400 |
| commit | ecd60a56ebd6bdc347a486f53da7de0febef58cf (patch) | |
| tree | efea34ffa8b81deab7f186756222035e3ed1f2af /src | |
| parent | 1b6c26db976596e74ddaf5da8d0f43a63ccee063 (diff) | |
| download | libgit2-ecd60a56ebd6bdc347a486f53da7de0febef58cf.tar.gz | |
conflicts: when adding conflicts, remove staged
When adding a conflict for some path, remove the staged entry.
Otherwise, an illegal index (with both stage 0 and high-stage
entries) would result.
Diffstat (limited to 'src')
| -rw-r--r-- | src/index.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/index.c b/src/index.c index 561fe73c4..19432b18c 100644 --- a/src/index.c +++ b/src/index.c @@ -1314,6 +1314,21 @@ int git_index_conflict_add(git_index *index, (ret = index_entry_dup(&entries[2], INDEX_OWNER(index), their_entry)) < 0) goto on_error; + /* Remove existing index entries for each path */ + for (i = 0; i < 3; i++) { + if (entries[i] == NULL) + continue; + + if ((ret = git_index_remove(index, entries[i]->path, 0)) != 0) { + if (ret != GIT_ENOTFOUND) + goto on_error; + + giterr_clear(); + ret = 0; + } + } + + /* Add the conflict entries */ for (i = 0; i < 3; i++) { if (entries[i] == NULL) continue; @@ -1321,7 +1336,7 @@ int git_index_conflict_add(git_index *index, /* Make sure stage is correct */ GIT_IDXENTRY_STAGE_SET(entries[i], i + 1); - if ((ret = index_insert(index, &entries[i], 1, true)) < 0) + if ((ret = index_insert(index, &entries[i], 0, true)) < 0) goto on_error; entries[i] = NULL; /* don't free if later entry fails */ |
