Commit 63ad439405e33081417bc87f523dab4a2d7b99af

Vicent Martí 2011-06-11T11:56:10

Merge pull request #253 from sschuberth/msvc10-fixes Msvc10 fixes

diff --git a/src/fileops.c b/src/fileops.c
index 98fc53a..2a78764 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -603,7 +603,7 @@ int gitfo_getcwd(char *buffer_out, size_t size)
 }
 
 #ifdef GIT_WIN32
-static inline time_t filetime_to_time_t(const FILETIME *ft)
+GIT_INLINE(time_t) filetime_to_time_t(const FILETIME *ft)
 {
 	long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
 	winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */
@@ -627,7 +627,7 @@ static int do_lstat(const char *file_name, struct stat *buf)
 			fMode |= S_IWRITE;
 
 		if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
-			fMode |= _S_IFLNK;
+			fMode |= S_IFLNK;
 
 		buf->st_ino = 0;
 		buf->st_gid = 0;
diff --git a/src/fileops.h b/src/fileops.h
index 4e6007a..ae8932b 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -98,6 +98,9 @@ extern int gitfo_mv_force(const char *from, const char *to);
 #ifdef GIT_WIN32
 #  define gitfo_lstat(p,b) gitfo_lstat__w32(p,b)
 #  define gitfo_readlink(a, b, c) gitfo_readlink__w32(a, b, c)
+
+   extern int gitfo_lstat__w32(const char *file_name, struct stat *buf);
+   extern int gitfo_readlink__w32(const char *link, char *target, size_t target_len);
 #else
 #  define gitfo_lstat(p,b) lstat(p,b)
 #  define gitfo_readlink(a, b, c) readlink(a, b, c)
diff --git a/src/index.c b/src/index.c
index 60b6584..08e2490 100644
--- a/src/index.c
+++ b/src/index.c
@@ -142,8 +142,8 @@ unsigned int index_create_mode(unsigned int mode)
 {
 	if (S_ISLNK(mode))
 		return S_IFLNK;
-	if (S_ISDIR(mode) || (mode & S_IFMT) == 0160000)
-		return 0160000;
+	if (S_ISDIR(mode) || (mode & S_IFMT) == (S_IFLNK | S_IFDIR))
+		return (S_IFLNK | S_IFDIR);
 	return S_IFREG | ((mode & 0100) ? 0755 : 0644);
 }
 
diff --git a/src/msvc-compat.h b/src/msvc-compat.h
index 6f38e48..2343ea8 100644
--- a/src/msvc-compat.h
+++ b/src/msvc-compat.h
@@ -12,14 +12,17 @@
 # define stat _stat64
 # define fstat _fstat64
 
-#define _S_IFLNK 0120000
-
 /* stat: file mode type testing macros */
+# define _S_IFLNK 0120000
+# define S_IFLNK _S_IFLNK
+
 # define S_ISDIR(m)   (((m) & _S_IFMT) == _S_IFDIR)
 # define S_ISREG(m)   (((m) & _S_IFMT) == _S_IFREG)
 # define S_ISFIFO(m)  (((m) & _S_IFMT) == _S_IFIFO)
 # define S_ISLNK(m)  (((m) & _S_IFMT) == _S_IFLNK)
 
+# define MAXPATHLEN MAX_PATH
+
 /* case-insensitive string comparison */
 # define strcasecmp   _stricmp
 # define strncasecmp  _strnicmp