cache-tree: mark istate->cache_changed on cache tree update
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
a5400efe29
commit
d0cfc3e866
25
cache-tree.c
25
cache-tree.c
@ -151,7 +151,7 @@ void cache_tree_invalidate_path(struct index_state *istate, const char *path)
|
|||||||
istate->cache_changed |= CACHE_TREE_CHANGED;
|
istate->cache_changed |= CACHE_TREE_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int verify_cache(const struct cache_entry * const *cache,
|
static int verify_cache(struct cache_entry **cache,
|
||||||
int entries, int flags)
|
int entries, int flags)
|
||||||
{
|
{
|
||||||
int i, funny;
|
int i, funny;
|
||||||
@ -236,7 +236,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int update_one(struct cache_tree *it,
|
static int update_one(struct cache_tree *it,
|
||||||
const struct cache_entry * const *cache,
|
struct cache_entry **cache,
|
||||||
int entries,
|
int entries,
|
||||||
const char *base,
|
const char *base,
|
||||||
int baselen,
|
int baselen,
|
||||||
@ -398,18 +398,19 @@ static int update_one(struct cache_tree *it,
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cache_tree_update(struct cache_tree *it,
|
int cache_tree_update(struct index_state *istate, int flags)
|
||||||
const struct cache_entry * const *cache,
|
|
||||||
int entries,
|
|
||||||
int flags)
|
|
||||||
{
|
{
|
||||||
int i, skip;
|
struct cache_tree *it = istate->cache_tree;
|
||||||
i = verify_cache(cache, entries, flags);
|
struct cache_entry **cache = istate->cache;
|
||||||
|
int entries = istate->cache_nr;
|
||||||
|
int skip, i = verify_cache(cache, entries, flags);
|
||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
return i;
|
return i;
|
||||||
i = update_one(it, cache, entries, "", 0, &skip, flags);
|
i = update_one(it, cache, entries, "", 0, &skip, flags);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
return i;
|
return i;
|
||||||
|
istate->cache_changed |= CACHE_TREE_CHANGED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,9 +598,7 @@ int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix)
|
|||||||
|
|
||||||
was_valid = cache_tree_fully_valid(active_cache_tree);
|
was_valid = cache_tree_fully_valid(active_cache_tree);
|
||||||
if (!was_valid) {
|
if (!was_valid) {
|
||||||
if (cache_tree_update(active_cache_tree,
|
if (cache_tree_update(&the_index, flags) < 0)
|
||||||
(const struct cache_entry * const *)active_cache,
|
|
||||||
active_nr, flags) < 0)
|
|
||||||
return WRITE_TREE_UNMERGED_INDEX;
|
return WRITE_TREE_UNMERGED_INDEX;
|
||||||
if (0 <= newfd) {
|
if (0 <= newfd) {
|
||||||
if (!write_locked_index(&the_index, lock_file, COMMIT_LOCK))
|
if (!write_locked_index(&the_index, lock_file, COMMIT_LOCK))
|
||||||
@ -698,7 +697,5 @@ int update_main_cache_tree(int flags)
|
|||||||
{
|
{
|
||||||
if (!the_index.cache_tree)
|
if (!the_index.cache_tree)
|
||||||
the_index.cache_tree = cache_tree();
|
the_index.cache_tree = cache_tree();
|
||||||
return cache_tree_update(the_index.cache_tree,
|
return cache_tree_update(&the_index, flags);
|
||||||
(const struct cache_entry * const *)the_index.cache,
|
|
||||||
the_index.cache_nr, flags);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ void cache_tree_write(struct strbuf *, struct cache_tree *root);
|
|||||||
struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
|
struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
|
||||||
|
|
||||||
int cache_tree_fully_valid(struct cache_tree *);
|
int cache_tree_fully_valid(struct cache_tree *);
|
||||||
int cache_tree_update(struct cache_tree *, const struct cache_entry * const *, int, int);
|
int cache_tree_update(struct index_state *, int);
|
||||||
|
|
||||||
int update_main_cache_tree(int);
|
int update_main_cache_tree(int);
|
||||||
|
|
||||||
|
|||||||
@ -265,9 +265,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)
|
|||||||
active_cache_tree = cache_tree();
|
active_cache_tree = cache_tree();
|
||||||
|
|
||||||
if (!cache_tree_fully_valid(active_cache_tree) &&
|
if (!cache_tree_fully_valid(active_cache_tree) &&
|
||||||
cache_tree_update(active_cache_tree,
|
cache_tree_update(&the_index, 0) < 0)
|
||||||
(const struct cache_entry * const *)active_cache,
|
|
||||||
active_nr, 0) < 0)
|
|
||||||
die(_("error building trees"));
|
die(_("error building trees"));
|
||||||
|
|
||||||
result = lookup_tree(active_cache_tree->sha1);
|
result = lookup_tree(active_cache_tree->sha1);
|
||||||
|
|||||||
@ -371,9 +371,7 @@ static int is_index_unchanged(void)
|
|||||||
active_cache_tree = cache_tree();
|
active_cache_tree = cache_tree();
|
||||||
|
|
||||||
if (!cache_tree_fully_valid(active_cache_tree))
|
if (!cache_tree_fully_valid(active_cache_tree))
|
||||||
if (cache_tree_update(active_cache_tree,
|
if (cache_tree_update(&the_index, 0))
|
||||||
(const struct cache_entry * const *)active_cache,
|
|
||||||
active_nr, 0))
|
|
||||||
return error(_("Unable to update cache tree\n"));
|
return error(_("Unable to update cache tree\n"));
|
||||||
|
|
||||||
return !hashcmp(active_cache_tree->sha1, head_commit->tree->object.sha1);
|
return !hashcmp(active_cache_tree->sha1, head_commit->tree->object.sha1);
|
||||||
|
|||||||
@ -56,11 +56,12 @@ static int dump_cache_tree(struct cache_tree *it,
|
|||||||
|
|
||||||
int main(int ac, char **av)
|
int main(int ac, char **av)
|
||||||
{
|
{
|
||||||
|
struct index_state istate;
|
||||||
struct cache_tree *another = cache_tree();
|
struct cache_tree *another = cache_tree();
|
||||||
if (read_cache() < 0)
|
if (read_cache() < 0)
|
||||||
die("unable to read index file");
|
die("unable to read index file");
|
||||||
cache_tree_update(another,
|
istate = the_index;
|
||||||
(const struct cache_entry * const *)active_cache,
|
istate.cache_tree = another;
|
||||||
active_nr, WRITE_TREE_DRY_RUN);
|
cache_tree_update(&istate, WRITE_TREE_DRY_RUN);
|
||||||
return dump_cache_tree(active_cache_tree, another, "");
|
return dump_cache_tree(active_cache_tree, another, "");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user