diff --git a/read-cache.c b/read-cache.c
index 2e40a344209e010e664758865846b63dc9546c1f..056b322fb0c83aeda378f548e13f84d4a65c1e29 100644 (file)
--- a/read-cache.c
+++ b/read-cache.c
else if (ce_compare_gitlink(ce))
changed |= DATA_CHANGED;
return changed;
else if (ce_compare_gitlink(ce))
changed |= DATA_CHANGED;
return changed;
+ case 0: /* Special case: unmerged file in index */
+ return MODE_CHANGED | DATA_CHANGED | TYPE_CHANGED;
default:
die("internal error: ce_mode is %o", ntohl(ce->ce_mode));
}
default:
die("internal error: ce_mode is %o", ntohl(ce->ce_mode));
}
{
SHA_CTX c;
struct cache_header hdr;
{
SHA_CTX c;
struct cache_header hdr;
- int i, removed;
+ int i, err, removed;
struct cache_entry **cache = istate->cache;
int entries = istate->cache_nr;
struct cache_entry **cache = istate->cache;
int entries = istate->cache_nr;
/* Write extension data here */
if (istate->cache_tree) {
/* Write extension data here */
if (istate->cache_tree) {
- unsigned long sz;
- void *data = cache_tree_write(istate->cache_tree, &sz);
- if (data &&
- !write_index_ext_header(&c, newfd, CACHE_EXT_TREE, sz) &&
- !ce_write(&c, newfd, data, sz))
- free(data);
- else {
- free(data);
+ struct strbuf sb;
+
+ strbuf_init(&sb, 0);
+ cache_tree_write(&sb, istate->cache_tree);
+ err = write_index_ext_header(&c, newfd, CACHE_EXT_TREE, sb.len) < 0
+ || ce_write(&c, newfd, sb.buf, sb.len) < 0;
+ strbuf_release(&sb);
+ if (err)
return -1;
return -1;
- }
}
return ce_flush(&c, newfd);
}
}
return ce_flush(&c, newfd);
}