Merge branch 'jk/write-broken-index-with-nul-sha1'
Earlier we started rejecting an attempt to add 0{40} object name to the index and to tree objects, but it sometimes is necessary to allow so to be able to use tools like filter-branch to correct such broken tree objects. * jk/write-broken-index-with-nul-sha1: write_index: optionally allow broken null sha1s
This commit is contained in:
13
read-cache.c
13
read-cache.c
@ -1818,8 +1818,17 @@ int write_index(struct index_state *istate, int newfd)
|
||||
continue;
|
||||
if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce))
|
||||
ce_smudge_racily_clean_entry(ce);
|
||||
if (is_null_sha1(ce->sha1))
|
||||
return error("cache entry has null sha1: %s", ce->name);
|
||||
if (is_null_sha1(ce->sha1)) {
|
||||
static const char msg[] = "cache entry has null sha1: %s";
|
||||
static int allow = -1;
|
||||
|
||||
if (allow < 0)
|
||||
allow = git_env_bool("GIT_ALLOW_NULL_SHA1", 0);
|
||||
if (allow)
|
||||
warning(msg, ce->name);
|
||||
else
|
||||
return error(msg, ce->name);
|
||||
}
|
||||
if (ce_write_entry(&c, newfd, ce, previous_name) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user