From: Junio C Hamano <junkio@cox.net>
To: Kay Sievers <kay.sievers@vrfy.org>
Cc: Linus Torvalds <torvalds@osdl.org>, git@vger.kernel.org
Subject: Re: git and symlinks as tracked content
Date: Wed, 04 May 2005 16:16:22 -0700 [thread overview]
Message-ID: <7vwtqemvjt.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20050504223532.GA22967@vrfy.org> (Kay Sievers's message of "Thu, 5 May 2005 00:35:32 +0200")
It seems to follow the original suggestion by Linus and looks
good. Some comments:
* It continues to assume that S_IFREG, S_IFDIR and S_IFLNK have
the same bit pattern everywhere. In the same spirit as we
store mode bits in network byte order, it may be a good time
to introduce something like this:
-#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
-#define create_ce_mode(mode) htonl(S_IFREG | ce_permissions(mode))
+#define CE_IFREG 0100000
+#define CE_IFDIR 0040000
+#define CE_IFLNK 0120000
+#define CE_IFMASK 0770000
+
+#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644) /* REG only */
+#define create_ce_mode(mode) htonl(S_ISREG(mode) ?
+ (CE_IFREG | ce_permissions(mode)) :
+ S_ISLNK(mode) ?
+ CE_IFLNK :
+ 0) /* what would we do for unknowns? */
* read-cache.c:cache_match_stat() needs to know about the
object type. It was allowed to assume that anything thrown
at it was a file, but not anymore. How about something like
this:
int cache_match_stat(struct cache_entry
{
unsigned int changed = 0;
+ switch (ntohl(ce->ce_mode) & CE_IFMASK) {
+ case CE_IFREG:
+ changed |= !S_ISREG(st->st_mode) ? TYPE_CHANGED : 0;
+ break;
+ case CE_IFLNK:
+ changed |= !S_ISLNK(st->st_mode) ? TYPE_CHANGED : 0;
+ break;
+ default:
+ die("internal error: ce_mode is %o", ntohl(ce->ce_mode));
+ }
(in cache.h)
#define INODE_CHANGED 0x0010
#define DATA_CHANGED 0x0020
+#define TYPE_CHANGED 0x0040
* update-cache.c:refresh_entry() needs to know that if the
type of the path changed, it would never match:
/*
- * If the mode has changed, there's no point in trying
+ * If the mode or type has changed, there's no point in trying
* to refresh the entry - it's not going to match
*/
- if (changed & MODE_CHANGED)
+ if (changed & (MODE_CHANGED | TYPE_CHANGED))
return ERR_PTR(-EINVAL);
if (compare_data(ce, st.st_size))
* (this is just a minor nit). Since you have st here,
st.st_size can be used to see how big a buffer you need to
prepare for readlink() here:
+ unsigned int len;
+ char target[1024];
+ ce->ce_mode = htonl(S_IFLNK);
+ len = readlink(path, target, sizeof(target));
+ if (len == -1 || len+1 > sizeof(target))
+ return -1;
* Probably diff.c needs to be made aware of this change.
next prev parent reply other threads:[~2005-05-04 23:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-03 18:33 git and symlinks as tracked content Kay Sievers
2005-05-03 19:02 ` Linus Torvalds
2005-05-03 19:10 ` Morten Welinder
2005-05-03 19:50 ` H. Peter Anvin
2005-05-03 19:57 ` Andreas Gal
2005-05-03 20:05 ` Linus Torvalds
2005-05-03 20:09 ` Kay Sievers
2005-05-03 21:30 ` Junio C Hamano
2005-05-03 21:51 ` Andreas Gal
2005-05-03 22:44 ` Junio C Hamano
2005-05-04 0:39 ` Sym-links, b/c-special files, pipes, ... Scope Creep Brian O'Mahoney
2005-05-03 22:56 ` git and symlinks as tracked content H. Peter Anvin
2005-05-03 23:16 ` Junio C Hamano
2005-05-03 23:18 ` H. Peter Anvin
2005-05-03 23:42 ` Linus Torvalds
2005-05-03 23:42 ` Junio C Hamano
2005-05-04 15:48 ` David A. Wheeler
2005-05-04 23:03 ` Daniel Barkalow
2005-05-05 6:09 ` Alan Chandler
2005-05-05 9:51 ` read-only git repositories David Lang
2005-05-05 12:39 ` Sean
2005-05-06 3:01 ` read-only git repositories (ancient history) David A. Wheeler
2005-05-05 21:23 ` git and symlinks as tracked content Daniel Barkalow
2005-05-03 20:23 ` Junio C Hamano
2005-05-04 22:35 ` Kay Sievers
2005-05-04 23:16 ` Junio C Hamano [this message]
2005-05-05 1:20 ` Kay Sievers
2005-05-05 2:13 ` Junio C Hamano
2005-05-05 12:38 ` Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vwtqemvjt.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=kay.sievers@vrfy.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).