summaryrefslogtreecommitdiff
path: root/builtin/update-index.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-09-26 16:09:20 -0700
committerJunio C Hamano <gitster@pobox.com>2016-09-26 16:09:20 -0700
commitebc63580a1287325eef85e96c436de494406fd0a (patch)
tree16f8b85f47ff2f47b1eaba5b55902196590ed7f1 /builtin/update-index.c
parent6a67695268562f67babdb7d5195c8a43cc4015fa (diff)
parent40e0dc17ce6f8b699c0f9426438362ed658293dc (diff)
downloadgit-ebc63580a1287325eef85e96c436de494406fd0a.tar.gz
Merge branch 'tg/add-chmod+x-fix'
"git add --chmod=+x <pathspec>" added recently only toggled the executable bit for paths that are either new or modified. This has been corrected to flip the executable bit for all paths that match the given pathspec. * tg/add-chmod+x-fix: t3700-add: do not check working tree file mode without POSIXPERM t3700-add: create subdirectory gently add: modify already added files when --chmod is given read-cache: introduce chmod_index_entry update-index: add test for chmod flags
Diffstat (limited to 'builtin/update-index.c')
-rw-r--r--builtin/update-index.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 73f6b3e1be..f3f07e7f1c 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -419,30 +419,18 @@ static int add_cacheinfo(unsigned int mode, const struct object_id *oid,
return 0;
}
-static void chmod_path(int flip, const char *path)
+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: