summaryrefslogtreecommitdiff
path: root/builtin/init-db.c
diff options
context:
space:
mode:
authorTorsten Bögershausen <tboegi@web.de>2014-11-21 09:34:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-11-21 19:06:25 (GMT)
commitc7bf68d6b4b538f86e530f6b01eca7ff432ffbbb (patch)
tree0c27b56b39775218382b5471fd38f433e9253b5a /builtin/init-db.c
parent1f32ecffd864ea5b339883f94463b0b69f4aeb35 (diff)
downloadgit-c7bf68d6b4b538f86e530f6b01eca7ff432ffbbb.zip
git-c7bf68d6b4b538f86e530f6b01eca7ff432ffbbb.tar.gz
git-c7bf68d6b4b538f86e530f6b01eca7ff432ffbbb.tar.bz2
init-db: improve the filemode trustability check
Some file systems do not support the executable bit: a) The user executable bit is always 0, e.g. VFAT mounted with -onoexec b) The user executable bit is always 1, e.g. cifs mounted with -ofile_mode=0755 c) There are system where user executable bit is 1 even if it should be 0 like b), but the file mode can be maintained locally. chmod -x changes the file mode from 0766 to 0666, until the file system is unmounted and remounted and the file mode is 0766 again. This been observed when a Windows machine with NTFS exports a share to Mac OS X via smb or afp. Case a) and b) are handled by the current code. Case c) qualifies as "non trustable executable bit" and core.filemode should be false, but this is currently not done. Detect when ".git/config" has the user executable bit set after creat(".git/config", 0666) and set core.filemode to false. Because the permission bits on the file is whatever the end user already had when we are asked to reinitialise an existing repository, and do not give any information on the filesystem behaviour, do this only when running "git init" to create a new repository. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/init-db.c')
-rw-r--r--builtin/init-db.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/init-db.c b/builtin/init-db.c
index a6d58fd..1e0749d 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -256,6 +256,8 @@ static int create_default_files(const char *template_path)
!lstat(path, &st2) &&
st1.st_mode != st2.st_mode &&
!chmod(path, st1.st_mode));
+ if (filemode && !reinit && (st1.st_mode & S_IXUSR))
+ filemode = 0;
}
git_config_set("core.filemode", filemode ? "true" : "false");