diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-05-16 11:51:50 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-16 11:51:50 +0900 |
commit | f767178a5ada848867a7378053897bdfbac32590 (patch) | |
tree | 5a6a8f49b53dd52fc5e31bdb6a67105642399d93 /read-cache.c | |
parent | d97141b0b94ae0206ac25ed6334709b18f98f186 (diff) | |
parent | a96d3cc3f65285f7d51c30fb3f630202b5347a57 (diff) | |
download | git-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.c | 5 |
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); |