зеркало из https://github.com/microsoft/git.git
Merge branch 'nd/split-index-null-base-fix'
Split-index fix. * nd/split-index-null-base-fix: read-cache.c: fix writing "link" index ext with null base oid
This commit is contained in:
Коммит
0efa3d74e7
|
@ -2900,7 +2900,8 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strip_extensions && istate->split_index) {
|
if (!strip_extensions && istate->split_index &&
|
||||||
|
!is_null_oid(&istate->split_index->base_oid)) {
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
|
|
||||||
err = write_link_extension(&sb, istate) < 0 ||
|
err = write_link_extension(&sb, istate) < 0 ||
|
||||||
|
@ -3195,7 +3196,7 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
|
||||||
ret = write_split_index(istate, lock, flags);
|
ret = write_split_index(istate, lock, flags);
|
||||||
|
|
||||||
/* Freshen the shared index only if the split-index was written */
|
/* Freshen the shared index only if the split-index was written */
|
||||||
if (!ret && !new_shared_index) {
|
if (!ret && !new_shared_index && !is_null_oid(&si->base_oid)) {
|
||||||
const char *shared_index = git_path("sharedindex.%s",
|
const char *shared_index = git_path("sharedindex.%s",
|
||||||
oid_to_hex(&si->base_oid));
|
oid_to_hex(&si->base_oid));
|
||||||
freshen_shared_index(shared_index, 1);
|
freshen_shared_index(shared_index, 1);
|
||||||
|
|
|
@ -440,24 +440,26 @@ void add_split_index(struct index_state *istate)
|
||||||
void remove_split_index(struct index_state *istate)
|
void remove_split_index(struct index_state *istate)
|
||||||
{
|
{
|
||||||
if (istate->split_index) {
|
if (istate->split_index) {
|
||||||
/*
|
if (istate->split_index->base) {
|
||||||
* When removing the split index, we need to move
|
/*
|
||||||
* ownership of the mem_pool associated with the
|
* When removing the split index, we need to move
|
||||||
* base index to the main index. There may be cache entries
|
* ownership of the mem_pool associated with the
|
||||||
* allocated from the base's memory pool that are shared with
|
* base index to the main index. There may be cache entries
|
||||||
* the_index.cache[].
|
* allocated from the base's memory pool that are shared with
|
||||||
*/
|
* the_index.cache[].
|
||||||
mem_pool_combine(istate->ce_mem_pool, istate->split_index->base->ce_mem_pool);
|
*/
|
||||||
|
mem_pool_combine(istate->ce_mem_pool,
|
||||||
|
istate->split_index->base->ce_mem_pool);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The split index no longer owns the mem_pool backing
|
* The split index no longer owns the mem_pool backing
|
||||||
* its cache array. As we are discarding this index,
|
* its cache array. As we are discarding this index,
|
||||||
* mark the index as having no cache entries, so it
|
* mark the index as having no cache entries, so it
|
||||||
* will not attempt to clean up the cache entries or
|
* will not attempt to clean up the cache entries or
|
||||||
* validate them.
|
* validate them.
|
||||||
*/
|
*/
|
||||||
if (istate->split_index->base)
|
|
||||||
istate->split_index->base->cache_nr = 0;
|
istate->split_index->base->cache_nr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can discard the split index because its
|
* We can discard the split index because its
|
||||||
|
|
|
@ -472,4 +472,22 @@ test_expect_success 'writing split index with null sha1 does not write cache tre
|
||||||
test_line_count = 0 cache-tree.out
|
test_line_count = 0 cache-tree.out
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'do not refresh null base index' '
|
||||||
|
test_create_repo merge &&
|
||||||
|
(
|
||||||
|
cd merge &&
|
||||||
|
test_commit initial &&
|
||||||
|
git checkout -b side-branch &&
|
||||||
|
test_commit extra &&
|
||||||
|
git checkout master &&
|
||||||
|
git update-index --split-index &&
|
||||||
|
test_commit more &&
|
||||||
|
# must not write a new shareindex, or we wont catch the problem
|
||||||
|
git -c splitIndex.maxPercentChange=100 merge --no-edit side-branch 2>err &&
|
||||||
|
# i.e. do not expect warnings like
|
||||||
|
# could not freshen shared index .../shareindex.00000...
|
||||||
|
test_must_be_empty err
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче