Merge pull request #4849 from libgit2/cmn/expose-gitfile-check path: export the dotgit-checking functions
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 116 117 118 119 120 121 122 123 124 125 126
diff --git a/include/git2/sys/path.h b/include/git2/sys/path.h
new file mode 100644
index 0000000..2a0c7e0
--- /dev/null
+++ b/include/git2/sys/path.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#ifndef INCLUDE_sys_git_path_h__
+#define INCLUDE_sys_git_path_h__
+
+#include "git2/common.h"
+
+GIT_BEGIN_DECL
+
+/**
+ * The kinds of git-specific files we know about.
+ *
+ * The order needs to stay the same to not break the `gitfiles`
+ * array in path.c
+ */
+typedef enum {
+ /** Check for the .gitignore file */
+ GIT_PATH_GITFILE_GITIGNORE,
+ /** Check for the .gitmodules file */
+ GIT_PATH_GITFILE_GITMODULES,
+ /** Check for the .gitattributes file */
+ GIT_PATH_GITFILE_GITATTRIBUTES
+} git_path_gitfile;
+
+/**
+ * The kinds of checks to perform according to which filesystem we are trying to
+ * protect.
+ */
+typedef enum {
+ /** Do both NTFS- and HFS-specific checks */
+ GIT_PATH_FS_GENERIC,
+ /** Do NTFS-specific checks only */
+ GIT_PATH_FS_NTFS,
+ /** Do HFS-specific checks only */
+ GIT_PATH_FS_HFS
+} git_path_fs;
+
+/**
+ * Check whether a path component corresponds to a .git$SUFFIX
+ * file.
+ *
+ * As some filesystems do special things to filenames when
+ * writing files to disk, you cannot always do a plain string
+ * comparison to verify whether a file name matches an expected
+ * path or not. This function can do the comparison for you,
+ * depending on the filesystem you're on.
+ *
+ * @param path the path component to check
+ * @param pathlen the length of `path` that is to be checked
+ * @param gitfile which file to check against
+ * @param fs which filesystem-specific checks to use
+ * @return 0 in case the file does not match, a positive value if
+ * it does; -1 in case of an error
+ */
+GIT_EXTERN(int) git_path_is_gitfile(const char *path, size_t pathlen, git_path_gitfile gitfile, git_path_fs fs);
+
+GIT_END_DECL
+
+#endif /* INCLUDE_sys_git_path */
diff --git a/src/path.h b/src/path.h
index fb41f96..e29a7f6 100644
--- a/src/path.h
+++ b/src/path.h
@@ -13,6 +13,8 @@
#include "buffer.h"
#include "vector.h"
+#include "git2/sys/path.h"
+
/**
* Path manipulation utils
*
@@ -645,42 +647,4 @@ extern bool git_path_isvalid(
*/
int git_path_normalize_slashes(git_buf *out, const char *path);
-/*
- * The order needs to stay the same to not break the `gitfiles`
- * array in path.c
- */
-typedef enum {
- GIT_PATH_GITFILE_GITIGNORE,
- GIT_PATH_GITFILE_GITMODULES,
- GIT_PATH_GITFILE_GITATTRIBUTES
-} git_path_gitfile;
-
-typedef enum {
- /* Do both NTFS- and HFS-specific checks */
- GIT_PATH_FS_GENERIC,
- /* Do NTFS-specific checks only */
- GIT_PATH_FS_NTFS,
- /* Do HFS-specific checks only */
- GIT_PATH_FS_HFS
-} git_path_fs;
-
-/**
- * Check whether a path component corresponds to a .git$SUFFIX
- * file.
- *
- * As some filesystems do special things to filenames when
- * writing files to disk, you cannot always do a plain string
- * comparison to verify whether a file name matches an expected
- * path or not. This function can do the comparison for you,
- * depending on the filesystem you're on.
- *
- * @param path the path component to check
- * @param pathlen the length of `path` that is to be checked
- * @param gitfile which file to check against
- * @param fs which filesystem-specific checks to use
- * @return 0 in case the file does not match, a positive value if
- * it does; -1 in case of an error
- */
-extern int git_path_is_gitfile(const char *path, size_t pathlen, git_path_gitfile gitfile, git_path_fs fs);
-
#endif