diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-06-27 09:56:49 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-27 09:56:49 -0700 |
commit | c49fd57bf472143b1a0bbfb246c91e6ea0f06887 (patch) | |
tree | f2d6588d8302f18d43beb1e4f285f034e3c38513 /read-cache.c | |
parent | 269085e16e26d5096b5458ae89d63eb27de26eb7 (diff) | |
parent | 4e55ed32db81d06a4f618e2cc0f9da0e223ae304 (diff) | |
download | git-c49fd57bf472143b1a0bbfb246c91e6ea0f06887.tar.gz git-c49fd57bf472143b1a0bbfb246c91e6ea0f06887.tar.xz |
Merge branch 'et/add-chmod-x'
"git update-index --add --chmod=+x file" may be usable as an escape
hatch, but not a friendly thing to force for people who do need to
use it regularly. "git add --chmod=+x file" can be used instead.
* et/add-chmod-x:
add: add --chmod=+x / --chmod=-x options
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/read-cache.c b/read-cache.c index d9fb78bc5..db2776605 100644 --- a/read-cache.c +++ b/read-cache.c @@ -630,7 +630,7 @@ void set_object_name_for_intent_to_add_entry(struct cache_entry *ce) hashcpy(ce->sha1, sha1); } -int add_to_index(struct index_state *istate, const char *path, struct stat *st, int flags) +int add_to_index(struct index_state *istate, const char *path, struct stat *st, int flags, int force_mode) { int size, namelen, was_same; mode_t st_mode = st->st_mode; @@ -659,7 +659,9 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, else ce->ce_flags |= CE_INTENT_TO_ADD; - if (trust_executable_bit && has_symlinks) + if (S_ISREG(st_mode) && force_mode) + ce->ce_mode = create_ce_mode(force_mode); + else if (trust_executable_bit && has_symlinks) ce->ce_mode = create_ce_mode(st_mode); else { /* If there is an existing entry, pick the mode bits and type @@ -720,12 +722,13 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st, return 0; } -int add_file_to_index(struct index_state *istate, const char *path, int flags) +int add_file_to_index(struct index_state *istate, const char *path, + int flags, int force_mode) { struct stat st; if (lstat(path, &st)) die_errno("unable to stat '%s'", path); - return add_to_index(istate, path, &st, flags); + return add_to_index(istate, path, &st, flags, force_mode); } struct cache_entry *make_cache_entry(unsigned int mode, |