read-cache: introduce chmod_index_entry
As there are chmod options for both add and update-index, introduce a new chmod_index_entry function to do the work. Use it in update-index, while it will be used in add in the next patch. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
22433ce461
commit
d9d7096662
@ -423,26 +423,14 @@ static void chmod_path(char flip, const char *path)
|
||||
{
|
||||
int pos;
|
||||
struct cache_entry *ce;
|
||||
unsigned int mode;
|
||||
|
||||
pos = cache_name_pos(path, strlen(path));
|
||||
if (pos < 0)
|
||||
goto fail;
|
||||
ce = active_cache[pos];
|
||||
mode = ce->ce_mode;
|
||||
if (!S_ISREG(mode))
|
||||
if (chmod_cache_entry(ce, flip) < 0)
|
||||
goto fail;
|
||||
switch (flip) {
|
||||
case '+':
|
||||
ce->ce_mode |= 0111; break;
|
||||
case '-':
|
||||
ce->ce_mode &= ~0111; break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
cache_tree_invalidate_path(&the_index, path);
|
||||
ce->ce_flags |= CE_UPDATE_IN_BASE;
|
||||
active_cache_changed |= CE_ENTRY_CHANGED;
|
||||
|
||||
report("chmod %cx '%s'", flip, path);
|
||||
return;
|
||||
fail:
|
||||
|
||||
Reference in New Issue
Block a user