Add "S_IFDIRLNK" file mode infrastructure for git links
This just adds the basic helper functions to recognize and work with git tree entries that are links to other git repositories ("subprojects"). They still aren't actually connected up to any of the code-paths, but now all the infrastructure is in place. The next commit will start actually adding actual subproject support. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Apr 9, 2007 at 21:14 UTC
9eec4795d44439cd170fb52c73827c728252648d
1 file changed
+19
-1
cache.h
+19
-1
@@ -24,6 +24,22 @@
24
#define DTYPE(de) DT_UNKNOWN
25
#endif
26
27
+/*
28
+ * A "directory link" is a link to another git directory.
29
+ *
30
+ * The value 0160000 is not normally a valid mode, and
31
+ * also just happens to be S_IFDIR + S_IFLNK
32
+ *
33
+ * NOTE! We *really* shouldn't depend on the S_IFxxx macros
34
+ * always having the same values everywhere. We should use
35
+ * our internal git values for these things, and then we can
36
+ * translate that to the OS-specific value. It just so
37
+ * happens that everybody shares the same bit representation
38
+ * in the UNIX world (and apparently wider too..)
39
+ */
40
+#define S_IFDIRLNK 0160000
41
+#define S_ISDIRLNK(m) (((m) & S_IFMT) == S_IFDIRLNK)
42
+
43
/*
44
* Intensive research over the course of many years has shown that
45
* port 9418 is totally unused by anything else. Or
@@ -104,6 +120,8 @@ static inline unsigned int create_ce_mode(unsigned int mode)
120
{
121
if (S_ISLNK(mode))
122
return htonl(S_IFLNK);
123
+ if (S_ISDIR(mode) || S_ISDIRLNK(mode))
124
+ return htonl(S_IFDIRLNK);
125
return htonl(S_IFREG | ce_permissions(mode));
126
}
127
static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned int mode)
@@ -121,7 +139,7 @@ static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned in
139
}
140
#define canon_mode(mode) \
141
(S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
124
- S_ISLNK(mode) ? S_IFLNK : S_IFDIR)
142
+ S_ISLNK(mode) ? S_IFLNK : S_ISDIR(mode) ? S_IFDIR : S_IFDIRLNK)
143
144
#define cache_entry_size(len) ((offsetof(struct cache_entry,name) + (len) + 8) & ~7)
145