Merge pull request #261 from Romain-Geissler/discovery-path-v2 Fix: GIT_PATH_PATH_SEPARATOR is now a semi-colon under Windows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
diff --git a/include/git2/common.h b/include/git2/common.h
index 9a27ac2..ba54ce4 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -76,6 +76,10 @@
# define GIT_FORMAT_PRINTF(a,b) /* empty */
#endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define GIT_WIN32 1
+#endif
+
/**
* @file git2/common.h
* @brief Git common platform definitions
@@ -86,6 +90,22 @@
GIT_BEGIN_DECL
+/**
+ * The separator used in path list strings (ie like in the PATH
+ * environment variable). A semi-colon ";" is used on Windows, and
+ * a colon ":" for all other systems.
+ */
+#ifdef GIT_WIN32
+#define GIT_PATH_LIST_SEPARATOR ';'
+#else
+#define GIT_PATH_LIST_SEPARATOR ':'
+#endif
+
+/**
+ * The maximum length of a git valid git path.
+ */
+#define GIT_PATH_MAX 4096
+
typedef struct {
char **strings;
size_t count;
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 2cb6bfa..6fd763c 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -151,9 +151,9 @@ GIT_EXTERN(int) git_repository_open3(git_repository **repository,
* @param across_fs If true, then the lookup will not stop when a filesystem device change
* is detected while exploring parent directories.
*
- * @param ceiling_dirs A colon separated of absolute symbolic link free paths. The lookup will
- * stop when any of this paths is reached. Note that the lookup always performs on start_path
- * no matter start_path appears in ceiling_dirs
+ * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR separated list of absolute symbolic link
+ * free paths. The lookup will stop when any of this paths is reached. Note that the
+ * lookup always performs on start_path no matter start_path appears in ceiling_dirs
* ceiling_dirs might be NULL (which is equivalent to an empty string)
*
* @return 0 on success; error code otherwise
diff --git a/src/common.h b/src/common.h
index c83e005..b6a6b4d 100644
--- a/src/common.h
+++ b/src/common.h
@@ -1,13 +1,11 @@
#ifndef INCLUDE_common_h__
#define INCLUDE_common_h__
+#include "git2/common.h"
+
/** Force 64 bit off_t size on POSIX. */
#define _FILE_OFFSET_BITS 64
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#define GIT_WIN32 1
-#endif
-
#include "git2/thread-utils.h"
#include "cc-compat.h"
@@ -47,13 +45,11 @@ typedef SSIZE_T ssize_t;
# endif
#endif
-#include "git2/common.h"
#include "git2/types.h"
#include "git2/errors.h"
#include "thread-utils.h"
#include "bswap.h"
-#define GIT_PATH_MAX 4096
extern int git__throw(int error, const char *, ...) GIT_FORMAT_PRINTF(2, 3);
extern int git__rethrow(int error, const char *, ...) GIT_FORMAT_PRINTF(2, 3);
diff --git a/src/fileops.h b/src/fileops.h
index ae8932b..953fc73 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -12,8 +12,6 @@
#include <fcntl.h>
#include <time.h>
-#define GIT_PATH_LIST_SEPARATOR ':'
-
#ifdef GIT_WIN32
#define GIT_PLATFORM_PATH_SEP '\\'
#else
diff --git a/tests/t12-repo.c b/tests/t12-repo.c
index d59095f..d403869 100644
--- a/tests/t12-repo.c
+++ b/tests/t12-repo.c
@@ -334,7 +334,7 @@ static int append_ceiling_dir(char *ceiling_dirs, const char *path)
return git__rethrow(error, "Failed to append ceiling directory.");
if (len)
- ceiling_dirs[len] = ':';
+ ceiling_dirs[len] = GIT_PATH_LIST_SEPARATOR;
return GIT_SUCCESS;
}