Ignore executable bit when adding files if filemode=0.
If the user has configured core.filemode=0 then we shouldn't set the execute bit in the index when adding a new file as the user has indicated that the local filesystem can't be trusted. This means that when adding files that should be marked executable in a repository with core.filemode=0 the user must perform a 'git update-index --chmod=+x' on the file before committing the addition. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
committed by
Junio C Hamano
parent
4dafd7d244
commit
fd28b34afd
@ -347,11 +347,13 @@ int add_file_to_index(const char *path, int verbose)
|
||||
ce->ce_mode = create_ce_mode(st.st_mode);
|
||||
if (!trust_executable_bit) {
|
||||
/* If there is an existing entry, pick the mode bits
|
||||
* from it.
|
||||
* from it, otherwise force to 644.
|
||||
*/
|
||||
int pos = cache_name_pos(path, namelen);
|
||||
if (pos >= 0)
|
||||
ce->ce_mode = active_cache[pos]->ce_mode;
|
||||
else
|
||||
ce->ce_mode = create_ce_mode(S_IFREG | 0644);
|
||||
}
|
||||
|
||||
if (index_path(ce->sha1, path, &st, 1))
|
||||
|
||||
Reference in New Issue
Block a user