aboutsummaryrefslogtreecommitdiff
path: root/builtin/update-index.c
diff options
context:
space:
mode:
authorThomas Gummerer <t.gummerer@gmail.com>2016-09-14 22:07:46 +0100
committerJunio C Hamano <gitster@pobox.com>2016-09-15 12:13:54 -0700
commitd9d7096662122f6b82ad6e4c08397b75906da78d (patch)
tree16d6fb77cdde3c6b2ca94be67436221767f40726 /builtin/update-index.c
parent22433ce4617b6ff30c9e9bf03b85d4bb244c3dec (diff)
downloadgit-d9d7096662122f6b82ad6e4c08397b75906da78d.tar.gz
git-d9d7096662122f6b82ad6e4c08397b75906da78d.tar.xz
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>
Diffstat (limited to 'builtin/update-index.c')
-rw-r--r--builtin/update-index.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 57bd5af14..8ef21fedc 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: