From d9d7096662122f6b82ad6e4c08397b75906da78d Mon Sep 17 00:00:00 2001 From: Thomas Gummerer Date: Wed, 14 Sep 2016 22:07:46 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- builtin/update-index.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'builtin') diff --git a/builtin/update-index.c b/builtin/update-index.c index 57bd5af144..8ef21fedc8 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -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)) - goto fail; - switch (flip) { - case '+': - ce->ce_mode |= 0111; break; - case '-': - ce->ce_mode &= ~0111; break; - default: + if (chmod_cache_entry(ce, flip) < 0) 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: -- cgit v1.2.3