Merge branch 'rs/pretty-add-again'
[gitweb.git] / read-cache.c
index f12da0dbb8b95fe234b07fcd536d794a1c6b5390..f0269200526bf17f7b9b04b3d0b80383c99e73b8 100644 (file)
@@ -2198,6 +2198,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
        int entries = istate->cache_nr;
        struct stat st;
        struct strbuf previous_name_buf = STRBUF_INIT, *previous_name;
+       int drop_cache_tree = 0;
 
        for (i = removed = extended = 0; i < entries; i++) {
                if (cache[i]->ce_flags & CE_REMOVE)
@@ -2248,6 +2249,8 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
                                warning(msg, ce->name);
                        else
                                return error(msg, ce->name);
+
+                       drop_cache_tree = 1;
                }
                if (ce_write_entry(&c, newfd, ce, previous_name) < 0)
                        return -1;
@@ -2266,7 +2269,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
                if (err)
                        return -1;
        }
-       if (!strip_extensions && istate->cache_tree) {
+       if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
                struct strbuf sb = STRBUF_INIT;
 
                cache_tree_write(&sb, istate->cache_tree);
@@ -2633,3 +2636,9 @@ void stat_validity_update(struct stat_validity *sv, int fd)
                fill_stat_data(sv->sd, &st);
        }
 }
+
+void move_index_extensions(struct index_state *dst, struct index_state *src)
+{
+       dst->untracked = src->untracked;
+       src->untracked = NULL;
+}