read-cache: be specific what part of the index has changed
cache entry additions, removals and modifications are separated out. The rest of changes are still in the catch-all flag SOMETHING_CHANGED, which would be more specific later. 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:
parent
ad837d9ef9
commit
e636a7b4d0
@ -56,7 +56,7 @@ static int mark_ce_flags(const char *path, int flag, int mark)
|
|||||||
else
|
else
|
||||||
active_cache[pos]->ce_flags &= ~flag;
|
active_cache[pos]->ce_flags &= ~flag;
|
||||||
cache_tree_invalidate_path(active_cache_tree, path);
|
cache_tree_invalidate_path(active_cache_tree, path);
|
||||||
active_cache_changed = 1;
|
active_cache_changed = SOMETHING_CHANGED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -268,7 +268,7 @@ static void chmod_path(int flip, const char *path)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
cache_tree_invalidate_path(active_cache_tree, path);
|
cache_tree_invalidate_path(active_cache_tree, path);
|
||||||
active_cache_changed = 1;
|
active_cache_changed = SOMETHING_CHANGED;
|
||||||
report("chmod %cx '%s'", flip, path);
|
report("chmod %cx '%s'", flip, path);
|
||||||
return;
|
return;
|
||||||
fail:
|
fail:
|
||||||
@ -889,7 +889,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
|
|||||||
INDEX_FORMAT_LB, INDEX_FORMAT_UB);
|
INDEX_FORMAT_LB, INDEX_FORMAT_UB);
|
||||||
|
|
||||||
if (the_index.version != preferred_index_format)
|
if (the_index.version != preferred_index_format)
|
||||||
active_cache_changed = 1;
|
active_cache_changed = SOMETHING_CHANGED;
|
||||||
the_index.version = preferred_index_format;
|
the_index.version = preferred_index_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
cache.h
5
cache.h
@ -268,6 +268,11 @@ static inline unsigned int canon_mode(unsigned int mode)
|
|||||||
|
|
||||||
#define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
|
#define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
|
||||||
|
|
||||||
|
#define SOMETHING_CHANGED (1 << 0) /* unclassified changes go here */
|
||||||
|
#define CE_ENTRY_CHANGED (1 << 1)
|
||||||
|
#define CE_ENTRY_REMOVED (1 << 2)
|
||||||
|
#define CE_ENTRY_ADDED (1 << 3)
|
||||||
|
|
||||||
struct index_state {
|
struct index_state {
|
||||||
struct cache_entry **cache;
|
struct cache_entry **cache;
|
||||||
unsigned int version;
|
unsigned int version;
|
||||||
|
11
read-cache.c
11
read-cache.c
@ -51,7 +51,7 @@ static void replace_index_entry(struct index_state *istate, int nr, struct cache
|
|||||||
remove_name_hash(istate, old);
|
remove_name_hash(istate, old);
|
||||||
free(old);
|
free(old);
|
||||||
set_index_entry(istate, nr, ce);
|
set_index_entry(istate, nr, ce);
|
||||||
istate->cache_changed = 1;
|
istate->cache_changed |= CE_ENTRY_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rename_index_entry_at(struct index_state *istate, int nr, const char *new_name)
|
void rename_index_entry_at(struct index_state *istate, int nr, const char *new_name)
|
||||||
@ -482,7 +482,7 @@ int remove_index_entry_at(struct index_state *istate, int pos)
|
|||||||
record_resolve_undo(istate, ce);
|
record_resolve_undo(istate, ce);
|
||||||
remove_name_hash(istate, ce);
|
remove_name_hash(istate, ce);
|
||||||
free(ce);
|
free(ce);
|
||||||
istate->cache_changed = 1;
|
istate->cache_changed |= CE_ENTRY_REMOVED;
|
||||||
istate->cache_nr--;
|
istate->cache_nr--;
|
||||||
if (pos >= istate->cache_nr)
|
if (pos >= istate->cache_nr)
|
||||||
return 0;
|
return 0;
|
||||||
@ -512,7 +512,7 @@ void remove_marked_cache_entries(struct index_state *istate)
|
|||||||
}
|
}
|
||||||
if (j == istate->cache_nr)
|
if (j == istate->cache_nr)
|
||||||
return;
|
return;
|
||||||
istate->cache_changed = 1;
|
istate->cache_changed |= CE_ENTRY_REMOVED;
|
||||||
istate->cache_nr = j;
|
istate->cache_nr = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,7 +1002,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
|
|||||||
istate->cache + pos,
|
istate->cache + pos,
|
||||||
(istate->cache_nr - pos - 1) * sizeof(ce));
|
(istate->cache_nr - pos - 1) * sizeof(ce));
|
||||||
set_index_entry(istate, pos, ce);
|
set_index_entry(istate, pos, ce);
|
||||||
istate->cache_changed = 1;
|
istate->cache_changed |= CE_ENTRY_ADDED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1101,6 +1101,7 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
|
|||||||
!(ce->ce_flags & CE_VALID))
|
!(ce->ce_flags & CE_VALID))
|
||||||
updated->ce_flags &= ~CE_VALID;
|
updated->ce_flags &= ~CE_VALID;
|
||||||
|
|
||||||
|
/* istate->cache_changed is updated in the caller */
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1182,7 +1183,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
|
|||||||
* means the index is not valid anymore.
|
* means the index is not valid anymore.
|
||||||
*/
|
*/
|
||||||
ce->ce_flags &= ~CE_VALID;
|
ce->ce_flags &= ~CE_VALID;
|
||||||
istate->cache_changed = 1;
|
istate->cache_changed |= CE_ENTRY_CHANGED;
|
||||||
}
|
}
|
||||||
if (quiet)
|
if (quiet)
|
||||||
continue;
|
continue;
|
||||||
|
@ -110,7 +110,7 @@ void resolve_undo_clear_index(struct index_state *istate)
|
|||||||
string_list_clear(resolve_undo, 1);
|
string_list_clear(resolve_undo, 1);
|
||||||
free(resolve_undo);
|
free(resolve_undo);
|
||||||
istate->resolve_undo = NULL;
|
istate->resolve_undo = NULL;
|
||||||
istate->cache_changed = 1;
|
istate->cache_changed = SOMETHING_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unmerge_index_entry_at(struct index_state *istate, int pos)
|
int unmerge_index_entry_at(struct index_state *istate, int pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user