compat: convert modes to use portable file type values
This adds simple wrapper functions around calls to stat(), fstat(), and lstat() that translate the operating system's native file type bits to those used by most operating systems. It also rewrites the S_IF* macros to the common values, so all file type processing is performed using the translated modes. This makes projects portable across operating systems that use different file type definitions. Only the file type bits may be affected by these compatibility functions; the file permission bits are assumed to be 07777 and are passed through unchanged. Signed-off-by: David Michael <fedora.dm0@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7fa1365c54
commit
d543d9c0f4
7
cache.h
7
cache.h
@ -64,13 +64,6 @@ unsigned long git_deflate_bound(git_zstream *, unsigned long);
|
||||
*
|
||||
* The value 0160000 is not normally a valid mode, and
|
||||
* also just happens to be S_IFDIR + S_IFLNK
|
||||
*
|
||||
* NOTE! We *really* shouldn't depend on the S_IFxxx macros
|
||||
* always having the same values everywhere. We should use
|
||||
* our internal git values for these things, and then we can
|
||||
* translate that to the OS-specific value. It just so
|
||||
* happens that everybody shares the same bit representation
|
||||
* in the UNIX world (and apparently wider too..)
|
||||
*/
|
||||
#define S_IFGITLINK 0160000
|
||||
#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK)
|
||||
|
Reference in New Issue
Block a user