summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-23 05:38:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-23 05:38:22 (GMT)
commitd658196f3c4b2478ebdff638e2c3e4fb2f9cbba2 (patch)
tree253a7b9f1778db6ec10b662d1c12101ea4cdba87 /unpack-trees.c
parent6b0f1d9c475038a54343c007193f1c81ae82b959 (diff)
parent7db118303aa04930bea66e855e8659e042f3fa5d (diff)
downloadgit-d658196f3c4b2478ebdff638e2c3e4fb2f9cbba2.zip
git-d658196f3c4b2478ebdff638e2c3e4fb2f9cbba2.tar.gz
git-d658196f3c4b2478ebdff638e2c3e4fb2f9cbba2.tar.bz2
Merge branch 'en/unpack-trees-split-index-fix'
The split-index feature had a long-standing and dormant bug in certain use of the in-core merge machinery, which has been fixed. * en/unpack-trees-split-index-fix: unpack_trees: fix breakage when o->src_index != o->dst_index
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 3b6c3ee..0f01be6 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1284,9 +1284,20 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
o->result.timestamp.sec = o->src_index->timestamp.sec;
o->result.timestamp.nsec = o->src_index->timestamp.nsec;
o->result.version = o->src_index->version;
- o->result.split_index = o->src_index->split_index;
- if (o->result.split_index)
+ if (!o->src_index->split_index) {
+ o->result.split_index = NULL;
+ } else if (o->src_index == o->dst_index) {
+ /*
+ * o->dst_index (and thus o->src_index) will be discarded
+ * and overwritten with o->result at the end of this function,
+ * so just use src_index's split_index to avoid having to
+ * create a new one.
+ */
+ o->result.split_index = o->src_index->split_index;
o->result.split_index->refcount++;
+ } else {
+ o->result.split_index = init_split_index(&o->result);
+ }
hashcpy(o->result.sha1, o->src_index->sha1);
o->merge_size = len;
mark_all_ce_unused(o->src_index);
@@ -1401,7 +1412,6 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
}
}
- o->src_index = NULL;
ret = check_updates(o) ? (-2) : 0;
if (o->dst_index) {
if (!ret) {
@@ -1412,12 +1422,13 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
WRITE_TREE_SILENT |
WRITE_TREE_REPAIR);
}
- move_index_extensions(&o->result, o->dst_index);
+ move_index_extensions(&o->result, o->src_index);
discard_index(o->dst_index);
*o->dst_index = o->result;
} else {
discard_index(&o->result);
}
+ o->src_index = NULL;
done:
clear_exclude_list(&el);