On Mon, Nov 02, 2015 at 08:08:26PM +0100, Nguyễn Thái Ngọc Duy wrote: > $X/gitdir is created, or refreshed, in order to keep a linked worktree > from being pruned. But while git file is used as the foundation for > linked worktrees, it's used for other purposes as well and we should > not create $X/gitdir in those cases. > > Tighten the check. Only update an existing file, which is an > indication this is a linked worktree. Hrm. I think this fixes the immediate problem, but it seems odd for us to rely on "does the file exist"[1]. We trigger this code unconditionally from read_gitfile_gently(). But .git files are a general-purpose mechanism. Shouldn't we be doing this only if we suspect we are working with a linked working tree directory in the first place? Or we do not know at all, because we are operating in the linked dir, and seeing the presence of the "gitdir" file is the only way we say "ah, it turns out we are linked, so we should take the opportunity to do some maintenance"? If the latter, then I guess this is the only way to do it. It does seem a bit strange to me that an otherwise read-only operation (reading the file) might involve writing[2]. -Peff [1] You check only !stat(), so it is not really "does it exist", but "can we stat it". I think that is OK, because this is an opportunistic update, and failing the stat should just mean we don't do the update. [2] I suspect this code should use write_file_gently(). What happens if I have a read-only linked checkout? -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html