From: Junio C Hamano Date: Thu, 05 May 2005 02:13:43 GMT Subject: Re: git and symlinks as tracked content Message-ID: <7vy8aul8rs.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <20050505012051.GA26201@vrfy.org> >>>>> "KS" == Kay Sievers writes: >> * It continues to assume that S_IFREG, S_IFDIR and S_IFLNK have >> the same bit pattern everywhere.... >> * read-cache.c:cache_match_stat() ... KS> Both included and updated. The second one, yes, but the first one is "not really". If you are going to do this: KS> +#define CE_IFREG 0100000 KS> +#define CE_IFDIR 0040000 KS> ... KS> +#define CE_IFMASK 0770000 then you need to touch these things: KS> + mode = ntohl(ce->ce_mode); KS> + if (S_ISLNK(mode)) { Here mode encodes type in CE_ format, so S_ISLNK() is bad. KS> @@ -165,7 +165,7 @@ static void prepare_temp_file(const char KS> } KS> strcpy(temp->hex, sha1_to_hex(null_sha1)); KS> sprintf(temp->mode, "%06o", KS> - S_IFREG |ce_permissions(st.st_mode)); KS> + S_IFREG | ce_permissions(st.st_mode)); KS> } Likewise here, although this is my bad. I did not know if you are going to take CE_ type suggestion so I left it as it was. There are more. "grep 'S_I[SF]' *.[ch] */*.[ch]" would tell us most if not all. We probably would want to have CE_ISLNK() and friends, parallel to S_ISLNK() and friends if we go this route. Does POSIX or something have nice to say that we do not have to worry about this? Or are the stat type bits really different on different Unixen? I used to do porting for living across a dozen or so different Unixen long time ago and I should know the answer to this kind of thing by heart, but I do not anymore X-<.