git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] init: don't reset core.filemode on git-new-workdirs.
@ 2021-03-21 12:28 Madhu
  2021-03-21 21:58 ` Junio C Hamano
  0 siblings, 1 reply; 13+ messages in thread
From: Madhu @ 2021-03-21 12:28 UTC (permalink / raw)
  To: git

From: Madhu <enometh@net.meer>

If the .git/config file is a symlink (as is the case of a .git created
by the contrib/workdir/git-new-workdir script) then the filemode tests
fail, and the filemode is reset to be false.  To avoid this only munge
core.filemode if .git/config is a regular file.
---
 builtin/init-db.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/builtin/init-db.c b/builtin/init-db.c
index dcc45bef51..b053107336 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -285,7 +285,8 @@ static int create_default_files(const char *template_path,
 	/* Check filemode trustability */
 	path = git_path_buf(&buf, "config");
 	filemode = TEST_FILEMODE;
-	if (TEST_FILEMODE && !lstat(path, &st1)) {
+	if (TEST_FILEMODE && !lstat(path, &st1)
+	    && (st1.st_mode & S_IFMT) == S_IFREG) {
 		struct stat st2;
 		filemode = (!chmod(path, st1.st_mode ^ S_IXUSR) &&
 				!lstat(path, &st2) &&
-- 
2.31.0.dirty

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-06-18  4:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21 12:28 [PATCH] init: don't reset core.filemode on git-new-workdirs Madhu
2021-03-21 21:58 ` Junio C Hamano
2021-03-22  2:40   ` Madhu
2021-03-22  4:53     ` Junio C Hamano
2021-03-22  9:04       ` Madhu
2021-03-22 18:02         ` Junio C Hamano
2021-03-23  3:57           ` Madhu
2021-03-23  6:39             ` Junio C Hamano
2021-03-23 16:53               ` Torsten Bögershausen
2021-03-23 17:45                 ` Junio C Hamano
2021-03-23 20:31                   ` Torsten Bögershausen
2021-03-23 20:50                     ` Junio C Hamano
2021-06-18  4:18               ` Madhu

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).