summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index.c15
-rw-r--r--src/tree.c6
2 files changed, 21 insertions, 0 deletions
diff --git a/src/index.c b/src/index.c
index fed067cb0..06bbcacee 100644
--- a/src/index.c
+++ b/src/index.c
@@ -959,6 +959,21 @@ void git_index_conflict_cleanup(git_index *index)
git_vector_remove_matching(&index->entries, index_conflicts_match);
}
+int git_index_has_conflicts(git_index *index)
+{
+ unsigned int i;
+ git_index_entry *entry;
+
+ assert(index);
+
+ git_vector_foreach(&index->entries, i, entry) {
+ if (index_entry_stage(entry) > 0)
+ return 1;
+ }
+
+ return 0;
+}
+
unsigned int git_index_reuc_entrycount(git_index *index)
{
assert(index);
diff --git a/src/tree.c b/src/tree.c
index 46b4a6dd1..7b47af347 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -497,6 +497,12 @@ int git_tree__write_index(git_oid *oid, git_index *index, git_repository *repo)
assert(oid && index && repo);
+ if (git_index_has_conflicts(index)) {
+ giterr_set(GITERR_INDEX,
+ "Cannot create a tree from a not fully merged index.");
+ return GIT_EUNMERGED;
+ }
+
if (index->tree != NULL && index->tree->entries >= 0) {
git_oid_cpy(oid, &index->tree->oid);
return 0;