summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-05-16 11:51:50 +0900
committerJunio C Hamano <gitster@pobox.com>2017-05-16 11:51:50 +0900
commitf767178a5ada848867a7378053897bdfbac32590 (patch)
tree5a6a8f49b53dd52fc5e31bdb6a67105642399d93 /read-cache.c
parentd97141b0b94ae0206ac25ed6334709b18f98f186 (diff)
parenta96d3cc3f65285f7d51c30fb3f630202b5347a57 (diff)
downloadgit-f767178a5ada848867a7378053897bdfbac32590.tar.gz
Merge branch 'jk/no-null-sha1-in-cache-tree'
Code to update the cache-tree has been tightened so that we won't accidentally write out any 0{40} entry in the tree object. * jk/no-null-sha1-in-cache-tree: cache-tree: reject entries with null sha1
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/read-cache.c b/read-cache.c
index 0d0081a11b..3339de8124 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2197,6 +2197,7 @@ static int do_write_index(struct index_state *istate, int newfd,
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)
@@ -2247,6 +2248,8 @@ static int do_write_index(struct index_state *istate, int newfd,
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;
@@ -2265,7 +2268,7 @@ static int do_write_index(struct index_state *istate, int newfd,
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);